Yeah, without -q netcat never disconnects from the first server:

-q seconds   after EOF on stdin, wait the specified number of seconds and
then quit.

I don't know if there's some alternative easy way to do that
programatically... Telnet might let you do it, but probably won't be as easy


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Jordy van Wolferen
> Sent: 19 November 2008 16:20
> To: Half-Life dedicated Linux server mailing list
> Subject: Re: [hlds_linux] (Possibly) Useful bash snippet for 
> getting totalplayer numbers using multiple netconport consoles
> 
> Thanks! I'm testing it, but my netcat (0.7.1) on arch linux 
> doesn't support -q and without it doesn't show anything. I'll 
> try to look into it, when I'm home. I was thinking about 
> making some simple scripts/tools too.
> 
> On Wed, Nov 19, 2008 at 4:17 PM,  <[EMAIL PROTECTED]> wrote:
> > The "status" output from the master netconport console of bunch of 
> > forked servers gives player numbers, but this includes bots 
> > controlling boss infected and survivors (which is why the 
> number is rarely between 1 and 3).
> > So if you want to get some kind of realistic aggregate 
> player numbers, 
> > or if indeed you're not using fork but are using netconport 
> consoles, 
> > you need something else:
> >
> > for i in `seq 9000 9012`; \
> > do echo -e "PASS swordfish\nstatus" \
> > | nc -q 1 localhost $i 2>/dev/null \
> > | egrep -m 1 "^players : [0-9] humans, [0-9] bots \([0-9] 
> max\) \((not
> > )?hibernating\)" \
> > | sed -r "s/^players : ([0-9]) humans, [0-9] bots \([0-9] 
> max\) \((not
> > )?hibernating\).*$/\1/"; done \
> > | awk 'BEGIN {total=0} {total +=$1} END {print total}'
> >
> > http://pastebin.127001.org/315
> >
> > This boils down to:
> > - Loop through netconport ports (change to suit)
> > - For each port, we want to issue the PASS command with appropriate 
> > password (no that's not our real password, this time :P ), and then 
> > the status command (alter password to suit; if not using passwords, 
> > remove everything except status)
> > - Use netcat to push that command to the server (change 
> localhost to 
> > your server's IP if you're not running this locally), close the 
> > connection after
> > 1 second, and silently redirect errors to the bit bucket (like if 
> > there's nothing listening on that port)
> > - Find the line containing the number of players
> > - Alter that line to _only_ display the number of players 
> and nothing 
> > else
> > - After looping through all servers, total up the numbers
> >
> > I know it says a 1 second delay per server, but it actually 
> goes a lot 
> > faster than that.
> >
> > Not sure if this is useful to anyone, but there it is.  Comments, 
> > suggestions, and improvements welcome :)
> >
> > Philip Cass
> >
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the 
> list archives, please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlds_linux
> >
> 
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list 
> archives, please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlds_linux
> 


_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlds_linux

Reply via email to