Kill a process
Posted by sharmila (sharmila), 27 January 2006Hi,
I want to kill a process I started.
Through expect script ,i started a process in the target.I need to kill the process in the target through expect script.On the target,I do kill [pid] to the particular process. But I need to kill the process on the target through a small expect script.I need to extract the pid on the target through a small script and use the same pid to kill it.
How to do this?
Thanks in advance,
Posted by admin (Graham Ellis), 28 January 2006Most daemon processes that you start will write a file (usually with an extension .pid) onto the file system of the machine on which they're running so that other processes can identify them later and easily signal to them.
Best advise is to find out the name of the "pid file" that your process write when it's started, and use the data in that within another expect script to stop the process.
Posted by sharmila (sharmila), 30 January 2006I couldn't find .pid file on the file system of the machine.
I dont want to kill the whole target process but i need to kill a process started on the target through a script.
Please help me on this one...
Posted by admin (Graham Ellis), 30 January 2006on 01/30/06 at 18:56:07, sharmila wrote:
Err ... what have I been doing?
You haven't told us what the remote process is - is it something that you've written yourself or some standard process? If we don't know, we're left guessing and can only provided very limited help / advise. How would you go about killing it manually from a telnet process? As a worst case scenario, you'll simply want to run that same manual kill process automated from Expect.
Posted by geno976 (geno976), 31 January 2006Sharmila,
If your script is the one that started the process via the spawn cmd, then you can modify it to store the pid into some variable.
set pid [spawn <whatever_process>]
Spawn returns the PID of the newly spawned process. So you can store the pid, and use exec to kill it at a later time.
Not sure if this is what you're talking about, but if not then you'll need to provide a better problem description..
Posted by admin (Graham Ellis), 31 January 2006Good thought, Geno!
Posted by sharmila (sharmila), 31 January 2006Thanks Graham&Geno.
Works for me when I saved the pid in a file and then i read the file back to kill it.
Thanks for all your help...
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho