2

Sorry if its to naive. I am wanting to write a simple PERL script that will accept two arguments(Here Commit Labels) which are taken as inputs to cleartool command and provides me with a suitable output. My Code:

#!/usr/bin/perl
$file1 = system('cleartool find . -version "lbtype($ARGV[0])" -print > filename1');
$file2 = system('cleartool find . -version "lbtype($ARGV[1])" -print > filename2');
$file3 = system('diff filename1 filename2 > changeset');
print $ARGV[0];
print $ARGV[1];
print $file3;
close filename1;
close filename2;
close changeset

The output now is 3 empty files: filename1,filename2 and changeset. But i need the files committed between the two committed labels.

Could anyone shed light as to where i am going wrong!!

Thanks in advance.

thepeleton
  • 59
  • 5

2 Answers2

2

try this:

$file1 = system("cleartool find . -version 'lbtype($ARGV[0])' -print > filename1");

instead of

$file1 = system('cleartool find . -version "lbtype($ARGV[0])" -print > filename1');
rams0610
  • 1,041
  • 10
  • 8
  • Thank you very much! It worked as i had expected. But could you reason out the difference of using ' "" ' and " ' ' " inside system() call that caused the difference? – thepeleton Sep 11 '13 at 08:33
  • If you use variables in single quotes those variables are not interpolated. perl treats variables as string literals. if you use double quotes perl interpolates them as variables – rams0610 Sep 11 '13 at 08:55
0

You have also some Perl package to facilitate the execution of cleartool commands.

That would allow to directly get the result in an array, instead of a file (even though you can dump that array in a file if you need to)

@res = ClearCase::CtCmd::exec("find . -version 'lbtype($ARGV[0])' -print");
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250