Wednesday, 19 October 2011

How to create perforce user non-interactively

I was trying to create perforce user account using “p4 user -i” option. I wanted to bulk rename perforce login-ID's due to change in our organization policy.

Here is the command.
p4 user -i -f < tempfile.txt

Where typically a tempfile.txt will be of the form
----------------------------------------------------------------------------------------------
# cat user-template.txt
# A Perforce User Specification.
#
#  User:        The user's user name.
#  Type:        Either 'service' or 'standard'. Default: 'standard'. Read only.
#  Email:       The user's email address; for email review.
#  Update:      The date this specification was last modified.
#  Access:      The date this user was last active.  Read only.
#  FullName:    The user's real name.
#  JobView:     Selects jobs for inclusion during changelist creation.
#  Password:    If set, user must have matching $P4PASSWD on client.
#  Reviews:     Listing of depot files to be reviewed by user.

User:   guruss1

Email:  siddesh.gurusiddappa@emc.com

Update: 2011/10/18 05:04:00

Access: 2011/10/18 06:17:32

FullName:       siddesh

----------------------------------------------------------------------------------------------



In context of the perl script:
open (WRITE, ">", "tempfile.txt") or die "Can't open temp file for writing.\n";
print WRITE "User: $uName\n\n";
print WRITE "Email: $email\n\n";
print WRITE "Update: $date\n\n";
print WRITE "FullName: $fName $lName - $prefix\n\n";
close WRITE;
system( "p4 user -i -f < tempfile.txt");

No comments:

Post a Comment