Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Kill a process

Posted by sharmila (sharmila), 27 January 2006
Hi,
 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,
Sharmila.

Posted by admin (Graham Ellis), 28 January 2006
Most 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 2006
I 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...
Thanks,
Sharmila.

Posted by admin (Graham Ellis), 30 January 2006
on 01/30/06 at 18:56:07, sharmila wrote:
Please help me on this one...


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 2006
Sharmila,

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..


HTH,
-geno

Posted by admin (Graham Ellis), 31 January 2006
Good thought, Geno!

Posted by sharmila (sharmila), 31 January 2006
Thanks 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...
Sharmila.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho