Re: using subprocess for non-terminating command

2007-07-04 Thread Jerry Hill
On 7/4/07, O.R.Senthil Kumaran <[EMAIL PROTECTED]> wrote: > Only when the program has executed and the output available, subprocess can > read through PIPE's stdout it seems ( not at any other time). > With killing, I loose the output. I think you have to read the data from the process's stdout be

Re: using subprocess for non-terminating command

2007-07-04 Thread Karthik Gurusamy
On Jul 4, 4:38 am, Phoe6 <[EMAIL PROTECTED]> wrote: > Hi all, > Consider this scenario, where in I need to use subprocess to execute a > command like 'ping 127.0.0.1' which will have a continuous non- > terminating output in Linux. > > # code > > >>>import subprocess > >>>process = subprocess.Popen

Re: using subprocess for non-terminating command

2007-07-04 Thread prikar20
On Jul 4, 12:29 pm, "O.R.Senthil Kumaran" <[EMAIL PROTECTED]> wrote: > * Jerry Hill <[EMAIL PROTECTED]> [2007-07-04 11:23:33]: > > > > > That's because you tied stdin to a pipe in your Popen call, but then > > tried to read from stdout. Try this instead: > > My mistake. I had just 'typed' the co

Re: using subprocess for non-terminating command

2007-07-04 Thread zacherates
> Only when the program has executed and the output available, subprocess can > read through PIPE's stdout it seems ( not at any other time). > With killing, I loose the output. This is untrue. >>> process.stdout.read() # Blocks until end of stream. >>> process.stdout.read(1) # Reads one character

Re: using subprocess for non-terminating command

2007-07-04 Thread O.R.Senthil Kumaran
* Jerry Hill <[EMAIL PROTECTED]> [2007-07-04 11:23:33]: > > That's because you tied stdin to a pipe in your Popen call, but then > tried to read from stdout. Try this instead: My mistake. I had just 'typed' the command in the mail itself and forgot to include the stdin, stdout, and stderr and

Re: using subprocess for non-terminating command

2007-07-04 Thread Steve Holden
O.R.Senthil Kumaran wrote: > * zacherates <[EMAIL PROTECTED]> [2007-07-04 12:09:03]: > >>> How should I handle these kind of commands (ping 127.0.0.1) with >>> subprocess module. I am using subprocess, instead of os.system because >>> at anypoint in time, I need access to stdout and stderr of exec

Re: using subprocess for non-terminating command

2007-07-04 Thread Jerry Hill
On 7/4/07, O.R.Senthil Kumaran <[EMAIL PROTECTED]> wrote: > Yes, I am aware of the ping -c option. But again even that does not help. > try > process = subprocess.Popen('ping -c 10 127.0.0.1', stdin=subprocess.PIPE, > shell=True) > process.stdout.read() # This will hang again. When I try that, it

Re: using subprocess for non-terminating command

2007-07-04 Thread O.R.Senthil Kumaran
* zacherates <[EMAIL PROTECTED]> [2007-07-04 12:09:03]: > > How should I handle these kind of commands (ping 127.0.0.1) with > > subprocess module. I am using subprocess, instead of os.system because > > at anypoint in time, I need access to stdout and stderr of execution. > > Ping, for one, allo

Re: using subprocess for non-terminating command

2007-07-04 Thread zacherates
> How should I handle these kind of commands (ping 127.0.0.1) with > subprocess module. I am using subprocess, instead of os.system because > at anypoint in time, I need access to stdout and stderr of execution. Ping, for one, allows you to set an upper bound on how long it runs (the -c option).

using subprocess for non-terminating command

2007-07-04 Thread Phoe6
Hi all, Consider this scenario, where in I need to use subprocess to execute a command like 'ping 127.0.0.1' which will have a continuous non- terminating output in Linux. # code >>>import subprocess >>>process = subprocess.Popen('ping 127.0.0.1', shell=True, >>>stdin=subprocess.PIPE, stdout=subp