ITPub博客

首页 > 应用开发 > IT综合 > perl脚本实现XXXlabelXXX查找version

perl脚本实现XXXlabelXXX查找version

原创 IT综合 作者:ppyeer 时间:2007-04-19 11:03:40 0 删除 编辑

clearcase不提供使用通配符*/?查找,没办法,网上找了一圈也没找到我想要的命令,正好在学perl,写了个脚本,终于是实现了通过label名字的部分字符,也可以查询version的功能。


在/vobs/myvob中查找lbtype为*1.2.1的所有version

#!/ap/local/5.8/bin/perl -w

$filename="label.txt";
$ct = "/usr/atria/bin/cleartool";
$viewname="LATEST";
$vobdir = "/vobs/myvob";
$sub_label = "1.2.1";

[@more@]

system "$ct setview -exec '$ct lstype -kind lbtype -s -invob $vobdir | grep $sub_label' $viewname > $filename";

open (MYFILE, $filename) || die "can not open for $! n";

while () {
chomp;
print "$_/n"; # "/"应该换成反斜杠,因为blog不认,只能用正斜杠代替了。
system "$ct setview -exec '$ct find $vobdir -ver "lbtype($_)" -print' $viewname ";
print "/n"; # "/"应该换成反斜杠
}

close (MYFILE);


++++++++++++++++++++++++++++++++++++++++++++++

代码更新,更简化:

#!/ap/local/5.8/bin/perl -w

$filename="label.txt";
$ct = "/usr/atria/bin/cleartool";
$viewname="LATEST";
$vobdir = "/vobs/myvob";
$sub_label = "1.2.1";

@line = `$ct setview -exec '$ct lstype -kind lbtype -s -invob $vobdir | grep $sub_label' $viewname `;

foreach (@line){
print "/n$_"; # "/"应该换成反斜杠
system "$ct setview -exec '$ct find $vobdir -ver "lbtype($_)" -print' $viewname";
}

-------------------------------------------------------------------

打印结果如下:

AAAA_V1.2.1

BBBB_V1.2.1

CCCC_V1.2.1

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/126198/viewspace-911525/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 新开通的留言版
请登录后发表评论 登录
全部评论
  • 博文量
    11
  • 访问量
    159557