Skip to main content

Execute command

Executes the command on the server

Function ExecuteCommand(Val Command, Val Connection) Export

ParameterCLI optionTypeRequiredDescription
Command--execStringCommand text
Connection--connArbitrary, Structure Of KeyAndValueConnection or connection parameters

Returns: Map Of KeyAndValue - Result of command execution


tip

When passing connection parameters, a new connection will be created and closed within the execution of a single command. To execute several commands (in OS and 1C versions), it is recommended to use a connection created in advance (see CreateConnection)


1C:Enterprise/OneScript code example
    URL          = "127.0.0.1:25565";
Password = "12We...";
WriteTimeout = 20;
ReadTimeout = 20;

ConnectionParams = OPI_RCON.FormConnectionParameters(URL, Password, ReadTimeout, WriteTimeout);
Connection = OPI_RCON.CreateConnection(ConnectionParams);

Command = "list";
Result = OPI_RCON.ExecuteCommand(Command, Connection);
    oint rcon ExecuteCommand \
--exec "list" \
--conn "{'url':'127.0.0.1:25575','password':'***','read_timeout':'20','write_timeout':'20'}"
Result
{
"data": "There are 0 of a max of 20 players online: ",
"result": true
}