[p4] Scripting Login

Weintraub, David david.weintraub at bofasecurities.com
Fri Jul 7 05:17:39 PDT 2006

I don't like putting passwords in my scripts because if someone looks at
the scripts, they can get the password. Not exactly a very secure
situation. You're much better off using long lived tickets whenever

However, if you really don't have a choice, then use the "-P" parameter
of the Perforce command. You can do something like this (I'm not 100%
familiar with MS-DOS Batch. Please excuse syntax booboos):

	set P4USER=david
	set P4PASSWORD=swordfish
	set P4PORT=p4server:1666

	set P4=p4 -u %P4USER% -P %P4PASSWORD% -p %P4PORT%


	%P4% files //...
	%P4% client -i < %TEMPFILE%


You get the idea. Basically, instead of using "p4" in your scripts, use
"%P4%". If the password, user, or port changes, all you have to do is
change the one line in your script where this is set.

-----Original Message-----
From: perforce-user-bounces at perforce.com
[mailto:perforce-user-bounces at perforce.com] On Behalf Of Vander Werf,
Sent: Thursday, July 06, 2006 10:33 AM
To: perforce-user at perforce.com
Subject: Re: [p4] Scripting Login

Yea, I wasn't clear in my description of what I am trying to do. These
are scripts to perform client tasks, and in the case of one server, I
don't have administrative privileges. For example, I have a script that
sets up the environment variables to access the server with a particular
workspace, then does a sync. I can't run this first thing in the morning
because my login has expired, so I want to be able to script the login.
Any ideas on what to do in this scenario?

More information about the perforce-user mailing list