diff options
Diffstat (limited to 'minecctl/rcon-commands.c')
-rw-r--r-- | minecctl/rcon-commands.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/minecctl/rcon-commands.c b/minecctl/rcon-commands.c index b6a216f..5f98b72 100644 --- a/minecctl/rcon-commands.c +++ b/minecctl/rcon-commands.c @@ -449,15 +449,29 @@ bool do_console(struct cfg *cfg) return true; } -bool do_command(struct cfg *cfg) +bool do_commands(struct cfg *cfg) { - int fd; struct server *server; + bool rv = true; + int fd; + + if (!cfg->commands) { + error("No commands to send"); + return false; + } server = server_get_default(cfg); fd = rcon_login(cfg, server); if (fd < 0) return false; - return send_cmd(fd, cfg->cmdstr); + for (char *const *cmd = cfg->commands; *cmd; cmd++) { + if (!send_cmd(fd, *cmd)) { + rv = false; + break; + } + } + + close(fd); + return rv; } |