pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin private pastebin - collaborative debugging tool What's a private pastebin?

Posted by Frymaster on Wed 19th Nov 15:15 (modification of post by Frymaster view diff)
diff | download | new post

  1. for i in `seq 9000 9012`; \
  2. do echo -e "PASS swordfish\nstatus" \
  3. | nc -q 1 localhost $i 2>/dev/null \
  4. | egrep -m 1 "^players : [0-9] humans, [0-9] bots \([0-9] max\) \((not )?hibernating\)" \
  5. | sed -r "s/^players : ([0-9]) humans, [0-9] bots \([0-9] max\) \((not )?hibernating\).*$/\1/"; done \
  6. | awk 'BEGIN {total=0} {total +=$1} END {print total}'
  7.  
  8. #This boils down to:
  9. #- Loop through netconport ports (change to suit)
  10. #- 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)
  11. #- 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)
  12. #- Find the line containing the number of players
  13. #- Alter that line to _only_ display the number of players and nothing else
  14. #- After looping through all servers, total up the numbers
  15.  
  16. #or, if all on one line:
  17.  
  18. 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}'

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings