[p4perl] Creating Users

Scott Lavender scott.lavender at visiprise.com
Tue Mar 7 11:45:30 PST 2006


Thanks for the help David. It works great. But, I have a follow up question. After modifying the user hash, what would be the corresponding way to save/create the user? I though it would be:
 
$p4->SaveUser( $user );
 
But, this does not seem to work.
 
Thanks.....Scott...

-----Original Message-----
From: Weintraub, David [mailto:david.weintraub at bofasecurities.com]
Sent: Tuesday, March 07, 2006 2:00 PM
To: Scott Lavender; p4perl at perforce.com
Subject: RE: [p4perl] Creating Users


You don't need the "-f" in the FetchUsers method. In fact, I'm not even sure it takes it. Try:
 
$user = $p4->FetchUser("testUser");
 
or
 
$user = $p4->Run("users", "-o", "testUser");
 
Which is the equivalent. If you need the "-f" parameter, you'll have to do this:
 
$user = $p4->Run("users", "-of", "testUser");
 
Fetch user will also return a new user too, so you can't use it to test to see if a user already exists. Use:
 
$userList = $p4->FetchUsers();
 
or 
 
$userList = $p4->Run("users", "-o");
 
if the first method doesn't work. Then, you have to parse what was returned to see if the user actually exists. I'm not 100% sure what this will return. You'll have to play around with it a bit. If you also set P4->Tagged(), this should return a reference to an array of hashes.


  _____  

From: p4perl-bounces at perforce.com [mailto:p4perl-bounces at perforce.com] On Behalf Of Scott Lavender
Sent: Tuesday, March 07, 2006 1:27 PM
To: p4perl at perforce.com
Subject: [p4perl] Creating Users


I need to write a script to create users. But, I am having problems performing a fetch on the user command. First I thought of using this:
 


  _____  

require P4;

my $p4 = new P4;
 
$p4->ParseForms();
$p4->Connect or die ( "Failed to connect to Perforce Server" );

my $fetched = $p4->FetchUser( "-f testUser" );
...

  _____  

 
Nothing is returned by the call to FetchUser. I assume it has to do with the force option. Is there a way to do this when creating new users?
 
Thanks.....
 
Scott Lavender | SCM Specialist | Visiprise | office: 770.619.4166 | www.visiprise.com <http://www.visiprise.com/> 
 
It is our company policy not to accept email of any data controlled by the International Traffic in Arms Regulations (ITAR). Please contact our Security Officer, Matt Reeves, for instructions and authorization to transmit such data.

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://maillist.perforce.com/pipermail/p4perl/attachments/20060307/0a71bccd/attachment.html


More information about the p4perl mailing list