Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
>> to do that you need to find the process ID. I'm not sure if >> popen() provides access to the PID but if not you could >> either search for it (this might be too slow) or just drop >> down to use fork rather than popen, as fork will return >> the PID. > >Would calling PS via another popen() and

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Liam Clarke
On 10/28/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > > >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') > > >>> f[0].write('\x03') > > > > Thank command works, but 'f[1]' is in read-only mode and I can't write > > to it. > > My command in the background is still not terminated. > > Thats al

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Liam Clarke
Alan Gauld wrote: > > You can read the output of popen into your program with > f.read(), but that will read all of the output after the program > has run. However I think you can readline() too to catch it > line by line. You can also write() data to f thus allowing you > to send your Ctrl-C.(You

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Kent Johnson
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

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
With what can I try and see what the PID is when using popen() or popen2() ? One thing that I noticed now is that when using popen() and the sys.exit(). The command is completed before my Python shell is terminated and if I use popen2(), sys.exit() works immediately but the ping command runs st

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') > >>> f[0].write('\x03') > > Thank command works, but 'f[1]' is in read-only mode and I can't write > to it. > My command in the background is still not terminated. Thats almost certainly because ping never reads its input. In that case

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
If I use popen2, I need to write to one of the tuple parts. >>> f = os.popen2('ping 192.168.8.85 -c 100 > cap1.txt') >>> f[0].write('\x03') Thank command works, but 'f[1]' is in read-only mode and I can't write to it. My command in the background is still not terminated. BTW I use Linux as OS.

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> >>> 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 dat

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Alan Gauld
> Python has a "signal" module in the standard library. Will that work? Yes potentially, but you still need to mess about with process ids etc to find which process to send the signal... And you would have to do the two things in separate threads since system() blocks your main program. Alan g

Re: [Tutor] os.system sending of break signals

2005-10-28 Thread Johan Geldenhuys
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 th

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread R. Alan Monroe
>> I send a command to os.system(cmd) and want to send a break signal in >> the same way. Is this possible? The break signal is ctrl c (^c). >> I tried this, but it didn't work: os.system('\x03') I think Hex 03 is >> the signal for ctrl c. > Its not possible with os.system because os.system runs

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread Alan Gauld
> I send a command to os.system(cmd) and want to send a break signal in > the same way. Is this possible? The break signal is ctrl c (^c). > I tried this, but it didn't work: os.system('\x03') I think Hex 03 is > the signal for ctrl c. Its not possible with os.system because os.system runs the c

Re: [Tutor] os.system sending of break signals

2005-10-27 Thread Hugo González Monteverde
Even if you could send a break signal, it would go to a new shell that os.system() invokes... Perhaps you know or can get the ID of the process you want to signal, a ctrl-c in a shell is equivalent to a SIGINT sent using os.kill() Please anyone in the list correct me if there is something I mis

[Tutor] os.system sending of break signals

2005-10-27 Thread Johan Geldenhuys
Hi all, I send a command to os.system(cmd) and want to send a break signal in the same way. Is this possible? The break signal is ctrl c (^c). I tried this, but it didn't work: os.system('\x03') I think Hex 03 is the signal for ctrl c. Thanks, ___ Tu