Command-line syntax

The basic syntax for commands is as follows:

p4 [global options] command [command-specific options] [command arguments]

The following options can be used with all p4 commands:

Global options Description and Example

-c clientname

Specifies the client workspace associated with the command. Overrides P4CLIENT.

$ p4 -c bruno_ws edit //JamCode/dev/jam/Jambase

-C charset

Specifies the client workspace’s character set. Overrides P4CHARSET.

$ p4 -C utf8 sync

-d directory

Specifies the current directory, overriding the environment variable PWD.

C:\bruno_ws> p4 -d c:\bruno_ws\dev\main\jam\Jambase Jamfile

-G

Format all output as marshaled Python dictionary objects (for scripting with Python).

$ p4 -G info

-H host

Specifies the hostname of the client computer, overriding P4HOST.

$ p4 -H deneb print //JamCode/dev/jam/Jambase

-I

Specify that progress indicators, if available, are desired. This option is not compatible with the -s and -G options.

At present, the progress indicator is only supported by two commands: submitting a changelist with p4 -I submit and “quietly” syncing files with p4 -I sync -q.

-L language

Specifies the language to use for error messages from the Helix Server. Overrides P4LANGUAGE. In order for this option to work, your administrator must have loaded support for non-English messages in the database.

$ p4 -L language info

-p port

Specifies the protocol, host and port number used to connect to the Helix Server service, overriding P4PORT.

$ p4 -p ssl:deneb:1818 clients

-P password

Supplies a Helix Server password, overriding P4PASSWD. Usually used in combination with the -u username option.

$ p4 -u earl -P secretpassword job

-r retries

Specifies the number of times to retry a command (notably, p4 sync) if the network times out.

-Q charset

Specifies the character set to use for command input and output; if you have set P4CHARSET to a UTF-16 or UTF-32 value, you must set P4COMMANDCHARSET to a non-UTF-16 or -32 value in order to use the p4 command-line client.

$ p4 -Q utf32 -C utf8 sync

-s

Prepend a tag to each line of output (for scripting purposes).

$ p4 -s info

-u username

Specifies a Helix Server user, overriding P4USER.

$ p4 -u bill user

-x filename

Read arguments, one per line, from the specified file. To read arguments from standard input, specify -x -.

$ p4 -x myargs.txt

-z tag

To facilitate scripting, displays the output of reporting commands in the format as that generated by p4 fstat.

$ p4 -z tag info

-q

Quiet mode; suppress all informational message and report only warnings or errors.

-V

Displays the version of the p4 executable.

To display the options for a specific command, issue the p4 help command. For example:

$ p4 help add

    add -- Open a new file to add it to the depot

    p4 add [ -c changelist# ] [ -d -f -I -n ] [ -t filetype ] file ...

     Open a file for adding to the depot.  If the file exists on the
     client, it is read to determine if it is text or binary. If it does
     not exist, it is assumed to be text.  To be added, the file must not
     already reside in the depot, or it must be deleted at the current
     head revision.  Files can be deleted and re-added.
[...]

For the full list of global options, commands, and command-specific options, see the Helix Core Command-Line (P4) Reference.

Also in this section: