| |||||||||||
How can I kill process Id's from within "Expect" Posted by pcmenon (pcmenon), 14 May 2005 Hi,I am running an interactive shell program where I am using expect utility. I am passing a command in expect ( such as watchqueue" ) that shows all the parsers/daemons running on the IP. Now the program runs successfully till the display of all parsers/daemons running on my IP. But I wanna kill this process ( watchqueue) to return to any prompt. How can I solve this problem, Please guide me in this regards. -- pcmenon Posted by admin (Graham Ellis), 14 May 2005 Your spawn process returns the process id, and you can then use that process id when you exec a kill. Don't get confused with the spawn_id variable ... that's different, but is also set by the spawn.Posted by pcmenon (pcmenon), 18 May 2005 Is there any command in expect to kill the spawn returned process ID ?I tried using normal "kill -9 $PID" but that didn't worked ? Posted by admin (Graham Ellis), 18 May 2005 exec kill -9 $PIDkill is an operating system dependant command and it's not built in to Tcl or expect. See Don Libes' book "Exploring Expect" for further examples Posted by pcmenon (pcmenon), 18 May 2005 Now I am facing problem as shown below: ------------------------------------------------------------------- Input:- set PID "pidof ssh" exec kill -12 $PID ------------------------------------------------------------------ OUtput: kill: can't find process "`pidof" kill: can't find process "ssh'" while executing "exec kill -12 `pidof ssh'" (file "./Engine_Parser.exp" line 442) ------------------------------------------------------------------ Posted by admin (Graham Ellis), 18 May 2005 You have to put the process id at the end of the "exec kill" command. In my example, I assumed that the variable PID contained the process ID; it should NOT contain a string of text in the way you have set it.I would expect you to spawn your process something like: set PID [spawn ........................] Where you should replace all the dots with the actual details of the process you're starting. 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.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |