Evan Chu
ClearCase Scripts

These Bash shell scripts automate some ClearCase tasks that are performed frequently. The software development environment in which these scripts will run is listed below.

  • Microsoft Windows XP
  • Cygwin with Bash shell
  • ClearCase for Microsoft Windows
With very minor modifications, these scripts can be adapted to run in a Linux or Unix environment.

Uncheckout unchanged files

I tend to checkout many files at once because I may edit them during development. After I finish my development, I need to uncheckout only those files that I did not change. This is the most useful script I wrote for ClearCase. You have to try this yourself.

The input to this script is a list of file paths separated by newlines. The script checks whether each file is different from its previous version. If the file is identical, then it is unchecked out.

The script uncheck-unchange.sh:

noChange=0 ### "cleartool diff" exit status means no difference

while read elem; do
cleartool diff -pre -options "-status_only" "$elem"
if [ $? = $noChange ]; then
cleartool uncheckout -rm "$elem"

This script can be combined with find-checkout.sh like this:
find-checkout.sh | uncheck-unchange.sh

I use the above command everyday.

Mount Versioned Object Base

All my previously mounted VOB's would disappear frequently. I don't really know why. So this script mounts them again without too much hassle.

The script mount-my-vob.sh:

### mount my clearcase vobs

vobs="\app1 \library2 \tool3"

for elem in $vobs; do
echo $elem
cleartool mount -persistent $elem
echo '----'

You must edit the "vobs" variable to substitute your own VOB names.

Find checked-out files

Recursively find all checked-out files from a list of directories specified as command-line parameters. The output is a list of file paths separated by newlines.

For example:

find-checkout.sh dir1 dir2

The script find-checkout.sh:
### list all checked-out files, recursively;
### the output pathnames are in unix format;
### find-checkout.sh [dir1 dir2 ...]

cleartool lscheckout -recurse -short -me -cview $@ | sed 's/\\/\//g'

The sed command converts the output of cleartool into Cygwin/Unix format. Specifically, the sed command changes backslashes (Windows format) into slashes (Cygwin/Unix format).

Find view-only files

Find view-only files from a list of directories specified as command-line parameters. The search is recursive and includes view-private files, view-private directories, view-private links, and checked-out files.

For example:

find-view-only.sh dir1 dir2

The script find-view-only.sh:
#!/bin/bash -x
### find view-only files: view-private files,
### view-private dirs, view-private links,
### checked-out versions

cleartool ls -view_only -short -recurse $@