Question

I am new to using clearcase. I have an assignment regarding this.

I have a file named Files.txt in unix, which contains a list of directory paths.

Example: Files.txt

/a/b/c/d
/e/f/g/
i/j/k/l/m/n

I want to find out, if the directories listed in the Files.txt is checked out or not. Can someone help me with a shell script(if there is a way, I am not sure) to find if the listed directories in the Files.txt are checked out or not.

I have tried this in unix command line,

Command: ct des d

Output:

directory version "d/@@/main/0"
  created 2008-07-09T07:18:26+05:30 by Anna (anna1.dummy@abc)
  Element Protection:
    User : anna : rwx
    Group: dummy   : rwx
    Other:          : r-x
  element type: directory

In this way, for Files.txt, it is difficult for me to parse through the output of "ct des directory_name" for each directory listed in the Files.txt and check if all the directories listed are checked out or not, because the Files.txt contains more than 100 directory paths. Is there a simple way to check if the directories in the Files.txt is checkout or not?

Was it helpful?

Solution

You need to loop on every line of your File.txt, and for each one describe and grep for CHECKEDOUT.

#!/bin/sh

lines=$(cat Files.txt)
while read -r line; do
  # do your descr there
  cleartool descr -l ${line}|grep CHECKEDOUT
done <<< "${lines}

Another way is to look for all checkout out folders, and for each one grep it from the Files.txt.

cleartool find . -type d -exec 'cleartool describe -fmt "%En %Rf\n" "$CLEARCASE_PN"' | grep "CHECKEDOUT" 

OTHER TIPS

Suppose if you are using PowerShell script then this way is the easiest to find whether a file is checkout.

(cleartool ls -short "<FileFullPath>").EndsWith("CHECKEDOUT")

It will return true if it is checkout.

For folder it is bit different as given below

(cleartool lscheckout -d "<FolderPath>").Length -gt 0

If it returns true then the folder is checkout . If the folder is not checkout there will no output string so the length would be zero and command would return false.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top