So, for a newbie like me I might struggle with this one :-(
I saw that the thread in comp.lang.python talks about a deamon flag for
a thread. This sounds like a idea that could work. I don't know how to
use that, but will use the example given there.
Thanks.
Kent Johnson wrote:
Johan Geldenhuys wrote:
I have script that calls a system command that I want to run for 5 minutes.
"""
import os
cmd = 'tcpdump -n -i eth0'
os.system(cmd)
"""
I can start a timer after the cmd is issued, but I don't know how to
send a control signal to stop the command after I issued it. This is
normally from the shell ^c.
This is problematic. In general there is no clean way to kill a thread in Python. The usual approach is to set a flag which the thread checks but this won't work for you.
A recent thread in comp.lang.python has some discussion and suggestions but it is inconclusive:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/94281f5a797489b1/ebca44930a016f74?q=os.system+thread&rnum=5&hl=en#ebca44930a016f74
Kent
|
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor