Jump to content

Creating clients through batch files

p4 client

  • Please log in to reply
2 replies to this topic

#1 Elliott Lock

Elliott Lock

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 01 August 2019 - 11:52 AM


I have a large number of machines 30+ which all require workspaces. Seems simple enough, just run p4 client right?

Well what I also need to do is define each clients specfification to be custom to the machine its on. This includes information specficiation like:
- Client (name)
- Root
- Options
- Stream

In short, things which are stored in the specficiation file (I believe). I waant to do all of this without having to interact with each machine, excluding the action of just running the batch file. The execution should effectively be silent.

Assuming I have the above values (I'd be calling OS commands like %computername% to get them). How would I pass in the information so the workspaces are correctly setup?

Many Thanks,


#2 Sambwise


    Advanced Member

  • Members
  • PipPipPip
  • 1130 posts

Posted 01 August 2019 - 02:53 PM

The pieces of the solution here are:
  • p4 client -i to read the spec definition from stdin rather than opening an editor to modify a file on disk
  • p4 client -o to write an auto-generated spec definition to stdout so you don't need to generate it yourself
  • The shell's | (pipe) operator to direct one command's stdout to another's stdin
  • --field global option to p4 to modify individual fields of an outgoing spec on the fly
Put it all together and you have something like:

p4 -c CLIENT --field "Root=ROOT" --field "Options=noclobber rmdir etc" --field "Stream=STREAM" client -o | p4 client -i

The --field option is undoc; see this blog post from back in the day for a little more info on it: https://www.perforce...nd-line-roundup

#3 Elliott Lock

Elliott Lock

    Advanced Member

  • Members
  • PipPipPip
  • 36 posts

Posted 09 August 2019 - 03:22 PM

This worked great. Thank you very much

Also tagged with one or more of these keywords: p4 client

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users