1

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?

Petryanu
  • 141
  • 1
  • 9

2 Answers2

2

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" 
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi Vonc, thanks for the solution. It works for me. Pleas explain me what (cleartool describe -fmt "%En %Rf\n" "$CLEARCASE_PN") does in the second case or where can i find its explanation. Thanks in Advance – Petryanu Feb 14 '14 at 07:56
  • 1
    @Petryanu It uses `fmt_ccase` (http://pic.dhe.ibm.com/infocenter/cchelp/v7r1m2/topic/com.ibm.rational.clearcase.cc_ref.doc/topics/fmt_ccase.htm) in order to dispay the element name (`%En`) and the checkout status (`%Rf`) – VonC Feb 14 '14 at 08:05
0

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.

Samselvaprabu
  • 16,830
  • 32
  • 144
  • 230