>> 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
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
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
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
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
> >>> 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
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.
> >>> 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
> 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
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
>> 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
> 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
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
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
14 matches
Mail list logo