Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

C/C++ API Documentation | 2025.1

# ClientApi::Run( const char *, ClientUser * )

Run a P4 Server command and return when it completes.

Virtual? | No |
Class | `ClientApi` |
Arguments | `const char *func` | the name of the command to run
| `ClientUser *ui` | a pointer to a `ClientUser` object
Returns | `void` |

## Notes

The `func` argument to `Run()` is the P4 Server command to run, (for instance, `info` or `files`). Command arguments are not included and must be set separately with `StrDict::SetArgv()`.

Initialize the connection with `Init()` before calling `Run()`, because without a connection, no commands can be sent to the server. Attempting to call `Run()` before `Init()` will probably result in a fatal runtime error.

`Run()` returns only after the command completes. Note that all necessary calls to `ClientUser` methods are made during the execution of `Run()`, as dictated by the server.

For managing the network connection of the run, relevant P4 Server configurables are:

- net.maxwait
- net.maxwaitclose

## Example

The code below runs `p4 info`, using `ClientUser::OutputInfo()` to display the results to the user. If a subclass of `ClientUser` is used here as the `ui` argument, that subclass’s implementation of `OutputInfo()` is used to display the results of the command.

    ClientApi client;
    ClientUser ui;
    Error e;

    client.Init( &e );
    client.Run( "info", &ui );
    client.Final( &e );

Your search for returned results