[Tutor] os.system sending of break signals

Kent Johnson kent37 at tds.net
Fri Oct 28 13:46:01 CEST 2005


Johan Geldenhuys wrote:
> So far:
> I tried
>  >>> f = os.popen('ping 192.168.8.85 -c 100 > cap2.txt')
> 
> You will see that I send the output from the command to a file, because 
> I want to test how stop the command before it reaches 100 pings.
> If I don't write the output to the file 'cap2.txt' and succeeds in 
> closing 'f', all the data returned to 'f' will be lost.
> 
> If i use:
>  >>>f.close()
> Then 'f' is not closed and the commands until 100 packets has been send.
> 
> So, I am still looking for a way to stop the command before it 
> terminates by itself. I will not be able to get the process ID in all he 
> cases to kill it that way.

Trent Mick's process.py shows how to kill a process started from Python.
http://starship.python.net/crew/tmick/

Kent



More information about the Tutor mailing list