Xonotic Forums
using rcon with ${....} - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Server Administration (https://forums.xonotic.org/forumdisplay.php?fid=16)
+--- Thread: using rcon with ${....} (/showthread.php?tid=5487)



using rcon with ${....} - TheGoodGamer - 05-16-2015

Hello Community,

i read this thread: http://forums.xonotic.org/showthread.php?tid=2987&highlight=SDL+binary

and i was impressed about the power of the xonotic console to deal with the cvar-system. So i decided to make some rcon scripts to use on my server

i tested this one (i was clientsided connteced as a player to the server):

rcon set tmp_hostname ${hostname}

when i then called

rcon tmp_hostname

it showed the contend of my local cvar hostname not from my server cvar hostname.
Is it possible to store the content for the server cvar "hostname" in another cvar?

I tried it another way, i have written a rcon tool with winapi to administrate my xonotic server. Works fine with all this secure stuff. But when i type

set tmp_hostname ${hostname}

and then prove the cvar tmp_hostname, then it's content is ${hostname}. Does that mean that all this cool cvar script stuff only works clientsided?


RE: using rcon with ${....} - TimePath - 05-16-2015

You could try using an alias to get the expansion you want: rcon "alias backup_hostname \"set tmp_hostname ${hostname}\"; backup_hostname"


RE: using rcon with ${....} - Mr. Bougo - 05-17-2015

You can escape ${hostname} by doing rcon set tmp_hostname $${hostname}

As for your winapi tool, I don't know why it would do that. There is a rcon client script in the "server" directory (rcon.pl). Does that fail too?

TimePath suggests aliases, maybe it's worth noting that aliases can not return their output through rcon, so you get no feedback (unless this has changed recently?). In this case it's no big deal, though.


RE: using rcon with ${....} - TheGoodGamer - 05-17-2015

@Mr. Bougo, thx i tested double escape without success.

I dont know how to use this script (rcon.pl), i'm a windows user, but i can explain, what i have done to test all this stuff:

For the test environment i use my windows pc, vmware workstation with "ubuntu 12.04-64Bit server" as a guestsystem, wireshark for recording the networktraffic, an UDP-Send tool, my rcon tool, a selfwritten serverbrowser:

I started 2 dedicated servers, one on my windows pc and one on vmware with ubuntu guest. Servers have been up, checked with serverbrowser and by connecting and playing! So next step...

I send the following as UDP to the servers (rcon_secure = 0): ÿÿÿÿrcon my_rconpassword set tmp_hostname "${hostname}" (all this recorded with wireshark)

And then i checked tmp_hostname, the content is "${hostname}", not "Xonotic 0.8.0 Server" as expected!!. In the xonotic server console i can read about a successfull rcon recieve. That is logical, how else could the former not existing cvar tmp_hostname now has a value!

The same when i use rcon_secure = 1 and do all the nice "ÿÿÿÿsrcon HMAC-MD4 TIME ........." stuff. Again: in the server console i can read about successfull rcon. BTW all the other rcon things, secure or not, successfully run with my rcon-tool and my udp-send tool. So i think i can say the tools are not the problem. As wireshark tells me that my strings are exactly send as i typed them.

When i'm directly type set tmp_hostname "${hostname}" on my xonotic consolewindow and then check tmp_hostname, then and only then it really has the content of hostname set. I can't imagine what's going wrong.

Has ever anyone tested this with a remote client or by directly sending the commands as udp?


RE: using rcon with ${....} - Mr. Bougo - 05-18-2015

Eh, you're right, it seems that rcon commands aren't subject to variable expansion (except when expanding aliases). I had no idea. There isn't much you can do then, other than follow TimePath's suggestion.


RE: using rcon with ${....} - Melanosuchus - 05-18-2015

There are different expansions rules on whether a command is executed in the console directly, as an alias or via rcon.

If you send commands via rcon, all characters which usually have special behaviour (double quotes, dollar sign, and semicolon) are treated as plain text, without any expansion of any kind.

If you want to write a tool to read/write cvars the best option is to do expansion on your side.
You can query for a cvar value by sending the cvar name as a single rcon line, the server will reply with "cvar_name" is "value" ["default_value"].


RE: using rcon with ${....} - TheGoodGamer - 05-24-2015

Ok thx for reply

@Melanosuchus
the point was not to write a tool for rcon, which can handle the $ stuff. I only used my tools to do a forensic analyse of the problem. My primary goal was to do this rcon stuff with the xonotic client. But i can follow your advice, if i decide to improve my rcon tool.

Maybe this is a topic for a request to the developers.