[p4] Detecting if a client exists (cheaply)

Jeff A. Bowles jab at pobox.com
Wed Feb 6 14:18:42 PST 2008


When in doubt, let it do the heavy work for you.

Please forgive the formatted output, below:

% p4 -c clientname -p public.perforce.com:1666 info
User name: jeff
Client name: clientname
Client host: Unstrung-Harp.local
Client unknown.
Current directory: /Users/jeff
Client address: 69.181.52.144:57697
Server address: perforce.com:1666
Server root: /usr/depot/public
Server date: 2008/02/06 14:17:17 -0800 PST
Server version: P4D/FREEBSD4/2007.3/142194 (2007/12/17)
Server license: Perforce Public Depot 2000 users (expires 2008/07/30)
%
% p4 -c jab.home -p public.perforce.com:1666 info
User name: jeff
Client name: jab.home
Client host: Unstrung-Harp.local
Client root: C:/jab/public.perforce.com
Current directory: /Users/jeff
Client address: 69.181.52.144:57699
Server address: perforce.com:1666
Server root: /usr/depot/public
Server date: 2008/02/06 14:17:23 -0800 PST
Server version: P4D/FREEBSD4/2007.3/142194 (2007/12/17)
Server license: Perforce Public Depot 2000 users (expires 2008/07/30)
%
%

So, although it touches the metadata (and you have to, to get the  
client name, anyhow), the simplest command I can think of is "p4 info".

"p4 info" will tell you that the client workspace name is, or is not,  
known already.

It's an easy cheat, I admit.

    -Jeff Bowles

On Feb 6, 2008, at 11:50 AM, Brad Holt wrote:

> Can't seem to find a quick way to do it.  I can dump the list and  
> check, but this will be part of a tool that may want to check  
> frequently, and for those folks on the other side of the world,  
> this would gum up the works.
>
> Running "p4 client testclient" will create a new "testclient" if it  
> does not exist.  Trying to delete a client that's not your will  
> throw a useful error either way (whether it exists or not), but if  
> that client is actually yours or ownerless, then you can  
> accidentally delete it.  I tried using "p4 client -t testclient"  
> which was useful if the client to use as a template did not exist,  
> but was actually very strange if it did.  The usual array of passed  
> in flags (-s, -ztag, etc) yielded nothing useful.
>
> One of you has surely sorted this out already surely.  Gimme.
>
> _______________________________________________
> perforce-user mailing list  -  perforce-user at perforce.com
> http://maillist.perforce.com/mailman/listinfo/perforce-user




More information about the perforce-user mailing list