Hello,
to search for pids of a unique screen, you can use this script:

#!/bin/bash
usage() {
        echo -e "Missing argument\nUsage: $0 unique-screen-name"
        exit
        }
get_screen_name() {
        screen -ls | grep [.]$1[[:space:]] | awk '{print $1}'
        }
get_screen_pid() {
        get_screen_name $1 | cut -d '.' -f1
        }
search_pids() {
        if [ "$1" == "$pid" ]; then
                break
        fi

        pgrep -P $1 | while read process; do
                #if (ps -p $process | awk '{print $4}' | grep -q
"^srcds_linux$"); then
                        echo "$process"
                #fi
                search_pids $process
        done
        }

if [ -z $1 ]; then usage; fi
search_pids `get_screen_pid $1`

http://pastebin.com/1MjqG1kQ

When you uncomment the if statement, the script will print only the
pids from srcds_linux.

To search for a given PID which uses an unknown Port, you can use
lsof. This tool is more powerful than netstat.
lsof -p $PROCESS_ID | grep "(LISTEN)" | awk '{print $8}'

The UDP-Port for GameConnections is the same as the TCP-Port.

You can also seek which PID is listening on a given port.
lsof -i :27015 | grep "(LISTEN)" | awk '{print $2}'

Greetings
Andre Müller

2011/1/10 Eric Riemers <[email protected]>:
> I have a fork not running at the moment, but searching with netstat -nlp (as
> root) does not show the pid of the process. Shows a couple of ip's in the
> list but no pids.
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Milton Ngan
> Sent: maandag 27 december 2010 20:04
> To: Half-Life dedicated Linux server mailing list
> Subject: Re: [hlds_linux] l4d2 forks control?
>
> Use "netstat -nlp" to find the process number of the fork by looking for the
> netcon/rcon port that it is listening on. Kill that process and that will
> send a SIGCHLD to the parent fork, which will cause it to respawn.
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Eric Riemers
> Sent: Monday, December 27, 2010 6:25 AM
> To: Half-Life dedicated Linux server mailing list
> Subject: [hlds_linux] l4d2 forks control?
>
> All,
>
> I've got l4d2 running with multiple forks, i know you can use the netcon
> port to do a broadcast so you can issue a command on all servers.
>
> But if 1 fork is down, and i cant reach that fork through the normal port to
> issue a quit. Can i use a command via netcon to restart that particular
> fork?
> Tried looking on google, but so far most where just examples on how to use
> forks with startups.
>
> Thanks,
>  Eric
>
> _______________________________________________
> 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
>

_______________________________________________
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