Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

rmpriv.pl

by Iron-Jeff (Acolyte)
on Oct 08, 2002 at 21:48 UTC ( [id://203767]=sourcecode: print w/replies, xml ) Need Help??
Category: Win32 Stuff
Author/Contact Info
Description: Deletes view-private files from a ClearCase view in Windows.
It should work in UNIX, too, but I think the Win32 category fits better because on unix you could simply do:

cleartool lspriv -s -oth | xargs rm -rf
#!/usr/bin/perl

# rmpriv [-q]
# Removes view private files (not checked-out files).
# Must be invokes within a ClearCase view.

use Getopt::Std;

getopts("q"); # quiet

my $lspriv = "cleartool lspriv -short -other";
open(LSPRIV, "$lspriv|") || die("Could not list private files");
my @files = <LSPRIV>;
close LSPRIV;

die("Error running cleartool lspriv") if ($? >> 8);

# chomp (@files);

my $count = 0;

print "Found " . scalar @files . " files.\n" unless $opt_q;

foreach my $file (sort {$b cmp $a} @files)
{
    chomp($file);
    $count += rmdir($file)  if     -d $file;
    $count += unlink($file) unless -d $file;
    print "deleted $file\n" unless -e $file || $opt_q;
}

print "Deleted $count files.\n" unless $opt_q;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://203767]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found