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 = "Jg9F...";
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);
    # JSON data can also be passed as a path to a .json file

oint rcon ExecuteCommand \
--url "93.125.42.204:25575" \
--pass "***" \
--wtout 20 \
--rtout 20 \
--exec "list" \
--conn "{'url':'93.125.42.204:25575','password':'***','read_timeout':20,'write_timeout':20}"
Result
{
"data": "There are 0/20 players online:",
"result": true
}