views:

589

answers:

3

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.

A: 

The command you need is p4 sync.

Carl Norum
+2  A: 

In a bat you can use the p4.exe commandline tool that comes with p4v and issue the sync command:

p4 sync myFileThatINeedToGetDaily.txt
akf
Thank for the response, I tried as you suggested, but I got an error "Access for user 'sanirudh' has not been enabled by 'p4 protect'."
anirudh
+2  A: 

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.

Cwan
Thanks for the response, I tried as you mentioned, but I got an error"H:\>p4 -u asahu -p merijan007 print -o c:\temp.txt //dbx/Releases/SC/1.1.0.6/build_info.txtPerforce client error: Connect to server failed; check $P4PORT. TCP connect to merijan007 failed. merijan007: service unknown.
anirudh
@anirudh: You need to use upper-case "-P". "-p" is used for overriding P4PORT on the command-line; as you can see from the error message p4.exe tries to connect to the server "merijan007".
Cwan
You can use p4 set P4USER=username and P4PASSWD=password so you don't need to put that stuff on the command line every time
Fraser Graham
@Fraser: Of course, but setting P4PASSWD is generally not a good idea from a security perspective.
Cwan
Thanks Cwan, I got following responseH:\>p4 -u asahu -P merijan007 -o c:\temp.txt //dbx/Proj0590_ZonePRO64/Software/releaseNotes.rtfPerforce client error: p4 -h for usage. Invalid option: -o.
anirudh
@anirudh: You are missing the actual "print" command, it should be: "p4 -u asahu -P merijan007 print -o c:\temp.txt //dbx/Proj0590_ZonePRO64/Software/releaseNotes.rtf"
Cwan