2

I have a file name myfile.txt in my desktop and I want to:

  • check whether this same file name is present or not in my ClearCase vob and
  • if present, then I want to read the file data without checking it out.

I want to write a script for that in c#.
I am using Clearcase Automation Library (CAL) in Visual Studio.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Raj
  • 33
  • 1
  • 1
  • 8
  • @mins I got this. This isn't about writing the script, but about the right `cleartool` commands to use in order to *get started* to write the script. The question is legitimate. – VonC Mar 23 '15 at 06:44

1 Answers1

0

Note: CAL (ClearCase Automation Library) might not be available for the latest versions of ClearCase (8.x): it is for CC7.1.2 or less.

Since you can execute cleartool command with it, your best approach is to first check if you can get the data you want through cleartool script, and then reporting that script in a CAL script:

my $cal_ct = Win32::OLE->new('ClearCase.Cleartool')  
or die "Could not create the ClearTool object\n";  

my $cclsvob = $cal_ct->CmdExec('lsvob');  

For reading data of any version without any checkout, you need to search in a dynamic view, where you can read any extended pathname (see "About the version-extended path").

For finding your file, you need a cleartool find command, with the option -nvi/sible:

Includes only those elements, along with their branches and versions, that are not visible (do not have a standard path name) in the view.

cd /path/to/view/AVob
cleartool find -all -name "myfile.txt" -nvis -print

Then you need to cat the %CLEARCASE_XPN% result

cleartool find -all -name "myfile.txt" -nvis -exec "type \"%CLEARCASE_XPN%\""
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • when i run this command in cleartool command window it shows error saying that -visible and -nvisible are only valid with -all or -avobs.I am new to cleartool and i never userd any command in cleartool so how can i access the file data if the file myfile.txt is present in the vob . – Raj Mar 23 '15 at 07:17
  • @Raushanraj True. Replace the '`.`' with `-all`. I have edited the answer accordingly. – VonC Mar 23 '15 at 07:22
  • i run this command but i am not getting any output . if possible can you give me solution using CAL library objects. – Raj Mar 23 '15 at 09:00
  • @Raushanraj you can execute the cleartool command in a CAL script, so the first step is to use the right cleartool command: are you using it in the path of a dynamic view? – VonC Mar 23 '15 at 09:05
  • @Raushanraj Is the vob (where `myfile.txt` should be ) mounted? Try also with `-avob` instead of `-all`, just to see if you get any result that way? – VonC Mar 23 '15 at 09:19
  • let me tell you with an example i have a directory name myFile( path:- Z:\myvob\myFile) and inside this folder there are three file first.txt ,second.txt and third.txt. I have another file fourth.txt in my desktop these are the thing that i want to perform:- 1.Check if fourth.txt is present or not in Z:\myvob\myFile and return the result(for my case result is false means fourth.txt is not present in Z:\myvob\myFile) 2.if the file let say fourth.txt is present in the dir Z:\myvob\myFile then check out the file and make changes in the file data and again check in. – Raj Mar 23 '15 at 09:50
  • @Raushanraj in that case, that means you are only after the file if it is visible (you do not want to find a file no longer visible because it wes deleted in the past) Do I understand you correctly? – VonC Mar 23 '15 at 09:52
  • In that case, try the simpler query: `cleartool find . -name "myfile.txt" -print`: that should give you an idea if the file is there or not in your view. – VonC Mar 23 '15 at 09:58
  • This command is running but were i can get the result like true or false for this query. – Raj Mar 23 '15 at 10:04
  • @Raushanraj simply by storing the output in a String: if the output is empty => false, if it is not empty => true. `my $ccres = $cal_ct->CmdExec("cleartool find Z:\myvob -name \"myfile.txt\" -print");` – VonC Mar 23 '15 at 12:21
  • Thank you So much it Works. i am using C# so i used this : string result = ct.CmdExec(@"find Z:\myVob\Projects -name myfile.txt -print"); – Raj Mar 24 '15 at 04:13
  • Well that is my first part of the soln now i know that the file is present so i want to copy the file in my system. – Raj Mar 24 '15 at 04:41