How to execute cleartool command within perl

风流意气都作罢 提交于 2019-12-22 18:36:43

问题


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.


回答1:


try this:

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

instead of

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



回答2:


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

  • package CCCmd: you can see it illustrated in "How can I interact with ClearCase from Perl?"
  • ClearCase::CtCmd

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");


来源:https://stackoverflow.com/questions/18734933/how-to-execute-cleartool-command-within-perl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!