Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to kill program from TCL script

Status
Not open for further replies.

mu6sys

Programmer
Dec 12, 2000
2
0
0
IL
Hi!
I run some programm using exec. How can I kill this program from the script(how can I find pid of the program)?
Thanks,
Alex
 
Assuming you're running some variant of Unix, here's an example:

catch {exec ls /tmp &} bg_pid

bg_pid should contain the pid of the background process. You can then exec a kill to finish the job.

Jeff.
 
Unfortunately, artim, something which should be trivial once again turns out to be very difficult on the Windows platform. (Oops. Letting my biases show...)

Take a look on the Tcl'ers Wiki ( for some ideas of how to accomplish this. Specifically, the pages and
Apparently, David Gravereaux's winutils extension can help out with this, too. Unfortunately, he's apparently still working on it, and there's virtually no documentation available for it. For pointers about it, check out - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
I need to make some scripts of bash shell...
How can I use exec properly...is ok to do that???

Thanks a lot
 
Tlist and kill exec'd from tclsh work fine.
I don't see what is so difficult about it.

The tools are there, prvided by M$ and all you have to do
prune the output.

If you look at the output of tlist this kind of easy code would work with some refinement.

proc Kill {pname} {
catch {set xprocmap [exec tlist]}
foreach line [split $xprocmap \n] {
foreach {id pn whatsit} [split $line " "] {
if {[string compare $pname [string tolower $pn]] == 0} {
catch {[exec kill $id]} err_kill
lappend dead $line
}
}
}
return $dead
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top