1

I am new to Clearcase and wanted to know is there any way to checkout the whole folder and sub-folders from Clearcase using command line without entering to the Clearcaese environment. I mean in this question one has to enter Clearcase environment and then type:

co -c "Reason for massive checkout" .../*

But I want to find out a way that works in a script or code in Perl for example.

Community
  • 1
  • 1
Royeh
  • 433
  • 5
  • 21

2 Answers2

1

As I describe in "How do I perform a recursive checkout using ClearCase?", you would still have to:

  • execute cleartool command
  • be in in the view in order to access the folder and sub-elements you want to checkout.

 system("cleartool co -c "Reason for massive checkout" .../*")

This seems to use multiple level of double-quotes: the ones inside the command should be escaped:

 system("cleartool co -c \\\"Reason for massive checkout\\\" .../*")

After discussion, this should also work:

system("cleartool find . -all -exec \"cleartool checkout -nc \\\"%CLEARCASE_PN%\\\"\"")
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks a lot for your quick answer. Well I could be in the view in order t access the folder and sub-folders, but because I am using a code and then will execute from there the mentioned command then the Perl could not recognize it as a ClearCase command! – Royeh Aug 10 '15 at 06:21
  • @Royeh what perl command are you using? What is the exact error message you see? What version of ClearCase are you using? What OS is your client? (and your ClearCase server?) – VonC Aug 10 '15 at 06:24
  • I am using `system("cleartool co -c "Reason for massive checkout" .../*")`. I have this error: `C:\Test>perl test.pm Bareword found where operator expected at test.pm line 12, near ""cleartool co -c "Reason" (Missing operator before Reason?) syntax error at test.pm line 12, near ""cleartool co -c "Reason " Execution of test.pm aborted due to compilation errors.` I am using ClearCase `Version: 8.0.1` on Windows 7. – Royeh Aug 10 '15 at 09:19
  • Thanks! but I have still an error! `cleartool: Error: Unable to access ".../*": Invalid argument.` – Royeh Aug 10 '15 at 09:26
  • @Royeh maybe the '*' is not correctly interpreted. As I mention in the linked answer, try the other approach `cleartool find somedir -type f -exec "cleartool checkout -c \"Reason for massive checkout\" \"%CLEARCASE_PN%\""` (this is the Windows syntax, but you still haven't mention the version and OS, as I asked before) – VonC Aug 10 '15 at 09:27
  • I am using ``Win7 Enterprise 64-bit`` OS and ClearCase ``Version: 8.0.1`` – Royeh Aug 10 '15 at 10:00
  • Thanks you so much! well, when I wrote the command ``cleartool find "C:/Test" -type f -exec "cleartool checkout -c \"Reason for massive checkout\" \"%CLEARCASE_PN%\"" `` inside my script and run it I have this error: `cleartool: Error: Unable to access "%CLEARCASE_PN%": No such file or directory.` – Royeh Aug 10 '15 at 10:18
0

I found very simple way which is more applied for me. Because I notice that the above answer is checking out the whole folders and sub-folders which are in the current drive while I need to check out only the current folder and it sub-folders. Then, here is what I found very helpful:

for checking out:

system 'cleartool find . -version "version(\main\LATEST)" -exec "cleartool co -nc "%CLEARCASE_PN%"';

and for checking in:

system 'cleartool find . -version "version(\main\LATEST)" -exec "cleartool ci -nc \"%CLEARCASE_PN%\""';
Royeh
  • 433
  • 5
  • 21