I'm writing a script to manage a server with linux. The script should include a notification system via in-game chat. This will work based on rcon servermsg. Here are some problems with the servermsg command:
rcon -c /usr/local/etc/rcon.yaml "servermsg test1"
test1 appears in the chat and on the screen
rcon -c /usr/local/etc/rcon.yaml "servermsg "test1""
rcon -c /usr/local/etc/rcon.yaml 'servermsg test1'
rcon -c /usr/local/etc/rcon.yaml 'servermsg "test1"'
rcon -c /usr/local/etc/rcon.yaml 'servermsg 'test1''
test1 appears
rcon -c /usr/local/etc/rcon.yaml "servermsg test1 test2"
rcon -c /usr/local/etc/rcon.yaml 'servermsg test1 test2'
rcon -c /usr/local/etc/rcon.yaml "servermsg 'test1 test2'"
nothing is displayed in chat or on the screen, sending fails
rcon -c /usr/local/etc/rcon.yaml "servermsg "test1 test2""
rcon -c /usr/local/etc/rcon.yaml 'servermsg 'test1 test2''
only test1 appears
rcon -c /usr/local/etc/rcon.yaml 'servermsg "test1 test2"'
test1 test2 appear
While you might suggest to write some direct notifications using the last option, I would like to use variables, but in bash you can't use a variable by placing it inside single quotes '_'. What should I do in this case? Can I expect the servermsg command to be improved? The quit or startrain commands, for example, work without having to include them in quotes.