[p4] How to list stale client spec's

Jeff Grills jgrills at junctionpoint.com
Wed Oct 18 15:47:40 PDT 2006


This script isn't as efficient as the one I posted a link to, since it has
to invoke a "p4 client" for each client.  That data is available from the
"p4 clients" command, but it's just not normally displayed; the -ztag option
will output the data in a format that's easier to process programmatically
and it also includes all the information passed back by the server.  Still,
the script below looks like it would do the job, and may even run on older
server versions than mine as some commands didn't used to obey -ztag (the
"p4 where" command, for instance, only recently supported -ztag formatted
output).

j

> -----Original Message-----
> From: perforce-user-bounces at perforce.com 
> [mailto:perforce-user-bounces at perforce.com] On Behalf Of 
> Kosinski, Teresa
> Sent: Wednesday, October 18, 2006 10:34 AM
> To: Helck, Christopher; perforce-user at perforce.com
> Subject: Re: [p4] How to list stale client spec's
> 
> Years ago, someone (wish I could give proper credit) posted a 
> nifty perl script that would list all of the clients in order 
> by their last used date.
> Here 'tis:
> 
> ***********************************
> 
> #!/usr/bin/perl
>  
> use strict;
> use warnings;
>  
> die "$0: Usage: $0\n" if @ARGV;
>  
> open(P4CLIENTS, "p4 clients|");
> my @clients;
> while(<P4CLIENTS>)
> {
>         chomp;
>         s/^Client\s+//;
>         s/\s+.*$//;
>         push(@clients, $_);
> }
> close(P4CLIENTS);
>  
> my @output;
> foreach my $client (@clients)
> {
>         my $owner = "";
>         my $access = "";
>  
>         open(P4CLIENT, "p4 client -o $client |");
>                 while(<P4CLIENT>)
>                 {
>                         chomp;
>                         $owner = $_ if (s/^Owner:\s+//);
>                         $access = $_ if (s/^Access:\s+//);
>                 }
>         close(P4CLIENT);
>  
>         push(@output, "$access\t$owner\t$client\n"); }
>  
> print sort @output;


More information about the perforce-user mailing list