This is a discussion on Help with killing within the Shell scripting forums, part of the Development/Scripting category; HI guys me again my counterstrike script is coming on greatguns now over 600 hundread lines long now (599 of ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
HI guys me again my counterstrike script is coming on greatguns now over 600 hundread lines long now (599 of them are coments
This is what the user see when they log in What do you wish to do ? anwser 1 to 10 1. Start css server 2. Change rcon pass word 3. View server start details 4. Add user details 5 View user detail 6. Server.cfg tick conf 7. Restart Servers 8. Teamspeak options 9. Search for records 10. Delete records Answer (or 'q' to quit)? all i need to do now is sort out options 7 and 8 . but i am having trouble with option 7 stopping and restart servers what i want to happen is if the user chooses to restart server he enters a port number then i need to get the pid number for that server and kill it. if they want to stop server i need to get two pid numbers and kill heres the two commands from ps -aux ./srcds_amd -game cstrike -port 27025 +ip 194.105.134.151 +maxplayer /bin/sh ./srcds_run -game cstrike -port 27025 +ip 194.105.1 to restart i just need to kill top line to stop server i would kil both Any help would be great |
| Sponsored Links | ||
|
|
|
||||
|
Quote:
Quote:
Code:
netstat -p -vant | grep PORT-NUMBER | awk '{ print $7}' | cut -d'/' -f1
netstat -p -vant | grep 27025 | awk '{ print $7}' | cut -d'/' -f1
Quote:
Code:
killall program-name
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
|
|||
|
thanks for your reply.
Not tried your line of code as unsure what it all means progress: i.ve used grep to get both lines for port i need saved them to file used sed to delete the line with run in it so iam only left with one line. where i am stuck now is how to get awk to turn $2 in to var so as i can then kill that proccess Code:
#!/bin/sh
tmpfile=tmpfile.txt
run=run
tmpfile1=tempile1.txt
[ ! -f $tmpfile ] && > $tmpfile
[ ! -f $tmpfile1 ] && > $tmpfile1
echo "Enter a port"
read port
ps auxww | grep $port >> $tmpfile #gets both line
sed "/$run/d" $tmpfile >> $tmpfile1 #deletes line i don t need
mv $tmpfile1 $tmpfile #1 line left $2 pid number i need
#need to cat $tmpfile then | awk '{print $2}'
# and kill $2
|
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Killing of a process and send a mail if the process doesnot come up within 2 minutes | Prince89 | Shell scripting | 1 | 02-11-2008 01:39 PM |