The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

rcon-minecraft - RCON interface for Minecraft servers

SYNOPSIS

rcon-minecraft --pass=password [options] command args ...

rcon-minecraft --pass=password [options] --command='cmd1' ...

OPTIONS

 --host=host        Hostname to connect to          [127.0.0.1]
 --port=port        Port number                         [25575]
 --password=pass    Password
 --timeout=sec      Timeout in seconds (float)             [30]
 --command='cmd'    Command to run. May be repeated.
   | --cmd='cmd'
 -c|--color         Use a colored output (modded servers)   [0]
 -q|--quiet         Suppress command output
 --echo             Echo the commands themselves to stdout
 -v|--version       Display version number and exit

Any remaining arguments on the commandline will be concatenated together and interpreted as a single command, as you might expect.

DESCRIPTION

rcon-minecraft provides a commandline interface to interact with a Minecraft server using the RCON protocol. You may specify commands via commandline options, or via standard input if no options are specified on the commandline.

OPTION DETAILS

--host=host

The hostname or IP address of the Minecraft server.

--port=port

The TCP port number to connect to. Default is the usual RCON port number, 25575. This must match the port number defined in your Minecraft server's server.properties file:

    rcon.port=25575
--password=password

The password required to connect to the Minecraft RCON. This is defined in your Minecraft server's server.properties file:

    rcon.password=

Note that the password must not be blank. A blank password defined in server.properties means that RCON is disabled on your server.

--timeout=sec

Normally rcon-minecraft will wait 30 seconds for the server to respond before it reports a timeout and exits. Setting a different timeout will affect all network operations, including connecting, and running commands. Some commands may legitimately take a long time to return, such as fill, reload, etc., so beware of setting this value too low.

--command='command args' | --cmd='command args'

Sends command args to the server and waits for the response. A forward slash is not needed (and will usually result in an error). When supplying arguments, enclose the command in quotation marks. Be sure to properly escape any special characters used by your shell.

To specify more than one command, simply repeat the --command option.

Examples:

    rcon-minecraft --pass=secret --cmd=list
    rcon-minecraft --pass=secret --cmd='team list' --cmd='say Hello, world'

If no commands are given, commands will be read from the standard input instead, and executed in order:

    rcon-minecraft --pass=secret < commands.txt

If you only want to run one command, as a convenience, you may skip the --command argument, and in this case only, arguments will be joined even if not enclosed in quotes:

    rcon-minecraft --pass=secret gamerule keepInventory true

Of course, proper shell escaping of special characters is still required. If this is a burden, consider using the above standard input method, or bypassing the shell by using the Net::RCON::Minecraft Perl module itself.

-c | --color

Some modded servers send back colored output. By default these color codes are stripped to give plaintext output. Setting -c instead causes command output to be displayed using ANSI escape codes. Whether those escape codes will actually produce colored output depends entirely on your terminal.

-q | --quiet

Suppresses output from commands (if any). Errors are still displayed, and if --echo is set, commands themselves are still echoed.

--echo

Echo commands themselves to standard output before they are run, prefixed by >:

    > list
    There are 2 of a max 20 players online: me, you
-v | --version

Display version number and exit.

--help

Display usage summary and exit.

ERRORS

Invalid arguments, connection errors, and unexpected/incorrect responses from the server will cause rcon-minecraft to display an error message and exit with a non-zero status code.

When running several commands in sequence, it is therefore possible for some of the commands to run, and the remainder not to run. If this results in an inconsistent state for your logic, and you need to perform a rollback, you are advised to run commands individually, or at least use --echo so you know which commands have been run. Of course, the full Perl module Net::RCON::Minecraft is installed on this machine, so you always have the option of coding complex logic directly in Perl.

SEE ALSO

AUTHOR

Ryan Thompson <rjt@cpan.org>

COPYRIGHT AND LICENSE

Copyright 2019 Ryan Thompson

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

http://dev.perl.org/licenses/artistic.html