送脚本了
没有注释.是rmelem的,使用的时候要小心
用法: perl $0 /path/to/dir 会把dir下的元素rmelem掉,使用前先lsco
复制内容到剪贴板
代码:
#!/usr/env/perl
#filename rmelem.pl
#copy right among, 2007-01-10, scmlife.com
#msn: lifeng29@msn.com
#use : perl rmelem.pl /path/to/dir
$OS="$ENV{'OS'}";
if ($OS=~ m/windows/i)
{
$nul="NUL";
}
else
{
$nul="/dev/null";
}
die "error option,please use: $0 pname \n" unless ($#ARGV eq 0)&&(-d $ARGV[0]);
if ($ARGV[0] !~ m/.*(lost\+found)/)
{
print "***Warnning,you will rmelem not in Lost+found !\nAre you want to continue: Yes or NO ? ";
chomp($yes=<STDIN>);
exit 1 if ($yes ne Yes);
}
$cmd1=qq(cleartool ls -r -s -vob_only -nxname $ARGV[0]);
$cmd2=qq(cleartool rmelem -force -c "rmelem by among" );
@filelist=`$cmd1 2>$nul`;
die "no file searched,command exit !!!\n" if ($#filelist eq -1);
print "***Warnning,you will rmelem this element:\n";
print @filelist;
print "***Are you want to continue: Yes or NO ?";
chomp($yes=<STDIN>);
exit 1 if ($yes ne Yes);
for (0..$#filelist)
{
chomp($file=pop(@filelist));
$file='"'.$file.'"';
push @newfilelist,$file;
}
system qq($cmd2 @newfilelist);
print "Command exec successful! \n";[
本帖最后由 among 于 2007-1-11 10:16 编辑 ]