how to login and download file using perforce command line

anirudh picture anirudh · Feb 16, 2010 · Viewed 19.8k times · Source

I have to download a file daily from perforce depot.

Presently I do it manually by selecting that file and using "Get latest version" option.

I want to write a script which I will schedule in my windows task schedular to get the file daily.

Please help me/guide me how to do this task automatically.

I am using p4v client software in windows XP operating system.

Answer

rjnilsson picture rjnilsson · Feb 16, 2010

Using P4V will make it hard to automate. I suggest you use the command-line client, p4.exe, instead. If there's only one file that you need the contents of you could simply use "p4 print" and avoid the need for creating a workspace (client) spec, e.g:

p4 print -o <local filename> //depot/path/to/file

Note that the above command requires you to be already logged on to the Perforce server. There's at least two ways around this:

1) Specify the username and password on the command-line (not really recommended for security reasons):

p4 -u myuser -P mypasswd print -o <local filename> //depot/path/to/file

2) Use a dedicated background user for the task, with an unlimited login expiration time (see p4 group and the Timeout field):

p4 -u backgrounduser print -o <local filename> //depot/path/to/file

A licensed "background user" designated for only performing automated tasks can be obtained at no further cost from Perforce Software. Try contacting Perforce support and ask them about this.