0
votes

I am new to the Perforce source control and I am trying to build a script that login to the server and get files to the working directory. Now I am able to connect to the server, set the working folder but I can not get the client.

This is the code of the connection to the server

$p4 = new P4;

$p4->SetProg($ScriptName);
$p4->SetVersion($ScriptRevision);
$p4->SetCharset($ENV{P4_CHARSET}); 
$p4->SetPort ($ENV{P4_IP_AND_PORT});
$p4->SetClient($ENV{P4_CLIENT});
$p4->SetUser($ENV{P4_USER});
$p4->SetPassword($ENV{P4_PWD}); 

$p4->Connect() or die "blblblblblb" ;

$p4->SetCwd($Working_dir); ## the dir exists

Now I need to create the client. Is this is the way ?

$p4->FetchClient( $ENV{P4_CLIENT} );  

I am getting back an object , but the Runsync command fail with error
Client 'xxxxxx' unknown - use 'client' command to create it

My question is how to create the client in Perl and how to use it in the sync command.

1

1 Answers

2
votes

To create the client in P4Perl, you'll need to:

  1. Construct the spec data for the new client, either field-by-field, or by using a template client.
  2. Issue $p4->SaveClient( $clientspec ); with your spec data.

Then, once you've created your client spec that describes your workspace, you'll need to tell P4Perl to use that client spec for your commands: $p4->SetClient( 'my-client-name' );

Then you can run your sync command.