How to execute cleartool command within perl

2019-05-27 11:51发布

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.

2条回答
贪生不怕死
2楼-- · 2019-05-27 12:19

try this:

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

instead of

$file1 = system('cleartool find . -version "lbtype($ARGV[0])" -print > filename1');
查看更多
我只想做你的唯一
3楼-- · 2019-05-27 12:39

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");
查看更多
登录 后发表回答