- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Killing process id
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 08:36 PM
тАО10-08-2003 08:36 PM
Killing process id
1. Connect to a remote machine through it's IP address and login to it.
my code:
spawn " telnet 10.10.x.x."
expect "login:"
send " Letme\r"
expect "assword:"
send " 123\r"
expect "#"
2. Then find out if XXX programme is running
send " [exec /bin/ps aux | grep XXX \r"
(XXX is the programme i want to get its process ID, could
be apache etc)
3. After the executing the above code, list of process id of XXX
programme will be listed.
What i want is to catch the first line of list and save it into the
variable, where i can then pick up the process id from it and then kill
it.
I have also tried to pipe the out of this comamnd send " [exec /bin/ps
aux | grep XXX \r" into the file, but the file can not be saved on the
remote machine.
Can any one show me a good and working code
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 09:00 PM
тАО10-08-2003 09:00 PM
Re: Killing process id
kill `remsh 10.10.x.x ps -ef | grep XXX | awk 'print $2;exit}'`
A bit dangerous though
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 09:08 PM
тАО10-08-2003 09:08 PM
Re: Killing process id
--
http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x80771cc6003bd6118fff0090279cd0f9%2C00.html&admit=716493758+1065690431101+28353475
--
From dim and distant experience I think remsh does fummy things to "expect".
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 11:31 PM
тАО10-08-2003 11:31 PM
Re: Killing process id
I usuall kill like this:
# kill $(UNIX95=1 ps -o pid= -C XXX)
Remotely this would be:
# remsh 10.10.x.x "kill $(UNIX95=1 ps -o pid= -C XXX)"
Obviuously, you like using expect with telnet :-)... so this could be an option:
spawn telnet 10.10.x.x
expect "login:"
send " Letme\r"
expect "assword:"
send " 123\r"
expect "#"
send "kill $(UNIX95=1 ps -o pid= -C XXX)\r"
expect "#"
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 11:42 PM
тАО10-08-2003 11:42 PM
Re: Killing process id
Ok, in a valiant attempt to re-deem myself, how about
$KILLPID=`remsh 10.10.x.x ps -ef | grep XXX | awk 'print $2;exit}`
remsh 10.10.x.x kill $KILLPID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-08-2003 11:46 PM
тАО10-08-2003 11:46 PM
Re: Killing process id
send "pids=`/bin/ps aux | grep XXX | awk \'\{ print \$1\}\'`\r"
send "kill -9 \$pids 2>/dev/null\r";
I have used this in my expect script to kill the remote process.
Regards
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2003 12:10 AM
тАО10-09-2003 12:10 AM
Re: Killing process id
will please explain your code
send "pids=`/bin/ps aux | grep XXX | awk \'\{ print \$1\}\'`\r"
send "kill -9 \$pids 2>/dev/null\r";
how can i check whether the would-be -removed process id is right, in other words,
can i first display with puts " "
that means i need a variable to store the value of send "pids= ....
and then call puts " the id is $myvariable"
how can be saved the output of send nto varaiable ??
rgds
Thanks all of you guys
waiting reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2003 01:08 AM
тАО10-09-2003 01:08 AM
Re: Killing process id
Yes, you can display the output of ps or ps -ef on the screen by not storing in a variable:
send "/bin/ps -ef | grep XXX | awk \'\{ print \$1\}\'\r"
In addition to that you can remove 2>/dev/null in the kill command to see the error if it is unable to terminate the process.
Regards,
Vasu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-09-2003 09:57 PM
тАО10-09-2003 09:57 PM
Re: Killing process id
this code does not work .
the comamnd send, sends this line of code.
pids=`/bin/ps aux | grep ftp | awk '{ print $1}
so only the above line is printed, and
`/bin/ps aux | grep ftp | awk '{ print $1}
is not exucuted at all.
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2003 12:25 AM
тАО10-10-2003 12:25 AM
Re: Killing process id
I wanted to connect to a remote machine and find out the process of ftp running on the remote machine, in order to kill it.
Than i have run this expect script
---------------------------------------
send {ps aux | grep ftp | awk '{print $2}'}; send "\r"
expect -re {([0-9]+).*}
set thepid $expect_out(1,string)
---------------------------------------
and i have got this result.
202
5482
13215
The middle number (5482) is the process id i am looking for.
My question is:
1. How can i get only this number and
display it on the screen.
2. How can i save this number on a variable
3. how can i kill this process using this number.
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-10-2003 12:50 AM
тАО10-10-2003 12:50 AM
Re: Killing process id
It would be much easier to use a shell script thus.
#!/usr/bin/sh
$KILLPID=`remsh 10.10.x.x ps -ef | grep ftp | grep -v grep | awk 'print $2;exit}`
remsh 10.10.x.x kill $KILLPID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-13-2003 12:04 AM
тАО10-13-2003 12:04 AM
Re: Killing process id
I want to use expect, not shell ( but thanks).
this is the code i am using
---------------------------------------------
send {ps aux | grep ftp | awk '{print $2}'}; send "\r"
expect -re {([0-9]+).*}
set thepid $expect_out(1,string)
---------------------------------------
and i have got this result.
202
5482
13215
The middle number (5482) is the process id i am looking for.
My question is:
1. How can i get only this number and
display it on the screen.
2. How can i save this number on a variable
3. how can i kill this process using this number.
thanks.