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 filesI 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:
#!/bin/bash
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"
fi
done
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 BaseAll 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:
#!/bin/bash
### mount my clearcase vobs
vobs="\app1 \library2 \tool3"
for elem in $vobs; do
echo $elem
cleartool mount -persistent $elem
echo '----'
done
You must edit the "vobs" variable to substitute your own VOB names.
Find checked-out filesRecursively 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:
#!/bin/bash
### 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 filesFind 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 $@