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 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
Kill a process

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

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

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

This page is a thread posted to the opentalk forum at 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., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho