Log in to Perforce from the command line

I would like to log into Perforce (P4) from the command line. I tried to use

p4 -u My_Username login 

But how can I provide a password. I need this to register a file from the command line.

+9
source share
3 answers

Before connecting to the server, install P4PORT (to tell the client where the server is) and P4USER (to tell the server who you are). P4PORT is indicated as the host name: port, port is usually (but not always) 1666. If you do not know what server address and Perforce username is, contact your sys administrator.

 p4 set P4PORT=your.server.hostname:1666 p4 set P4USER=your.username 

You can also use "set" or "setenv" or "export" according to your shell, but with 2014.2 or newer Perforce client (use "p4 -V" to check your version information), you can use "p4 to establish "as an ongoing cross-platform alternative. Another option is to use the "-u" and "-p" flags for each command you execute (for example, "p4 -p your.server.hostname: 1666 -u your.username sync ..."), but it gets tedious quickly .

To verify the correctness of your connection, run:

 p4 info 

If this gives you an error message or says that your user is unknown, contact your Perforce administrator to ensure that you have the correct P4PORT and P4USER values.

To enter, run:

 p4 login 

If the client can connect to the server and your username is correct, you will be prompted for a password. Enter it and you will be logged in.

If you are running scripts of Perforce commands that require credentials and you do not want your script to stop in the middle to request a password, my recommendation was to run "p4 login" as mentioned above at some point before running the script . The entry ticket will be saved on your computer, and the script will pick it up (provided that it connects to the same P4PORT and P4USER that you used to create the ticket). This is the safest method, because your plaintext password is not stored anywhere on your computer, and the login ticket cannot be used from other computers by default (also probably a limited time, depending on how your administrator configured that).

An unsafe method is to enter the plaintext password in your script:

 echo my.formerly.secure.password|p4 login 

Posting the plaintext of the password to the "p4 login" command will cause it to behave as if you entered it at the invitation and continue execution, rather than wait for additional input.

+21
source

Configure Run Login Information for Windows cmd

After installation, execute and configure your workspace via p4v, you can configure your workspace in Windows cmd.

You need the following command:

 p4 set 

Set up your server

 p4 set P4PORT= xx.xxx.xx.xxx:xxxxx 

Set your username

 p4 set P4USER=username 

Set your password

If you want to protect your password, you can download the MD5 encryptor to encrypt your password.

 p4 set P4PASSWD=hashedpasswd 

Install your client (workspace)

To select your workspace, you can use the following command:

 p4 set P4CLIENT=nameofworkspace 

Your workspace name might look like this: username_hostmachinename_numbers.

Set your ignore file

You can configure your ignore file so that when you add a project to execution, some files (build results) can be automatically ignored.

 p4 set P4IGNORE= filepath 
+3
source

I believe you can do this:

 p4 -P My_Password login 
0
source

Source: https://habr.com/ru/post/981966/


All Articles