Changing ladderlog parser without a server restart.

Post here if you need help setting up your server, etc.
Post Reply
Obsi
Posts: 7
Joined: Fri Sep 18, 2009 8:52 am

Changing ladderlog parser without a server restart.

Post by Obsi »

As I posted below, do not do this... you'll have issues matching player names, possible arbitrary shell command execution if you don't escape your vars correctly, and screen just doesn't play nice when you stuff a few hundred commands into it really quickly. Kyle's got the goods in post #2


This took a bit of digging, so I thought I'd share what I've found.

I remember coming across a thread where someone used tee to allow them to edit their script without requiring a server restart, but was unable to find it again.

I start the server in a screen session as normal, and then I run my parser script in a separate session like:

Code: Select all

tail -f -n0 /etc/arma/servers/servername/var/ladderlog.txt | php /etc/arma/servers/servername/settings/scriptname.php
The parser script connects to the screen session and sends commands via the following function

Code: Select all

function sendcmd($cmd){
        global $servername;
        `screen -S $servername -X stuff "$(printf '%s' "$cmd\015")"`;
}
I spent a few hours trying to find a way to send commands to screen before I stumbled across this, so hopefully this saves someone else some time.

Now you can edit your script at will, and just restart the tail session. Saves a lot of hassle restarting server and reconnecting.
Last edited by Obsi on Tue Sep 22, 2009 5:53 am, edited 1 time in total.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Changing ladderlog parser without a server restart.

Post by kyle »

we just output our parser to a file (through a pipe with tee or just write to the file in the parser) and then tail the file into the server
Image
Obsi
Posts: 7
Joined: Fri Sep 18, 2009 8:52 am

Re: Changing ladderlog parser without a server restart.

Post by Obsi »

But I love to find overly complex & easily exploitable solutions to problems that have a simple solution staring me right in the face >_<


Don't follow my advice in the first post people... everything will look fine and dandy for a while, and then all of a sudden you send a few hundred commands at the same time via that function, and screen barfs all over the place. I came back to a locked up screen session using up close to 100% CPU.
User avatar
sinewav
Graphic Artist
Posts: 6413
Joined: Wed Jan 23, 2008 3:37 am
Contact:

Re: Changing ladderlog parser without a server restart.

Post by sinewav »

In that case you might want to rename the topic to "How not to change ladderlog parser (without a server restart)" ...or something like that.
User avatar
kyle
Reverse Outside Corner Grinder
Posts: 1876
Joined: Thu Jun 08, 2006 3:33 pm
Location: Indiana, USA, Earth, Milky Way Galaxy, Universe, Multiverse
Contact:

Re: Changing ladderlog parser without a server restart.

Post by kyle »

then i'd have to edit my post LOL
Image
Post Reply