Re: subprocess pipe question

2011-02-25 Thread Rita
The results look right! I did a rather large test and the checksum passed. I will hold off any speed ups as you suggested. On Wed, Feb 23, 2011 at 8:37 PM, Rob Williscroft wrote: > Rita wrote in > news:[email protected] in > gmane.comp.python.general:

Re: subprocess pipe question

2011-02-23 Thread Rob Williscroft
Rita wrote in news:[email protected] in gmane.comp.python.general: [Top post relocated] > On Tue, Feb 22, 2011 at 7:57 PM, Rob Williscroft > wrote: > >> Rita wrote in >> news:[email protected] in >> gmane.co

Re: subprocess pipe question

2011-02-23 Thread Rita
This is a good solution thanks. You should wiki this somewhere. For extra points is there a way to speed up the p.stdout.read(bufsize) ? On Tue, Feb 22, 2011 at 7:57 PM, Rob Williscroft wrote: > Rita wrote in > news:[email protected] in > gmane.comp.

Re: subprocess pipe question

2011-02-22 Thread Rita
Thanks everyone for your replies. Chris, Unfortunately, I can't redirect the output to a file because there are other processes which use this processes output as stdin. Rob, I will give this a try. On Tue, Feb 22, 2011 at 7:48 PM, Chris Kaynor wrote: > > On Tue, Feb 22, 2011 at 3:44 PM, Rita

Re: subprocess pipe question

2011-02-22 Thread Rob Williscroft
Rita wrote in news:[email protected] in gmane.comp.python.general: > > When using wait() it works a bit better but not consistent > def run(cmd): > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > rc=p.wait() > print rc > return p.stdout > > W

Re: subprocess pipe question

2011-02-22 Thread Chris Kaynor
On Tue, Feb 22, 2011 at 3:44 PM, Rita wrote: > I have a process like this, > > def run(cmd): > #cmd=a process which writes a lot of data. Binary/ASCII data > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > > I would like to get cmd's return code so I am doing this, > > def run(cmd): > p=su

Re: subprocess pipe question

2011-02-22 Thread GMail Felipe
On 22/02/2011, at 20:44, Rita wrote: > I have a process like this, > > def run(cmd): > #cmd=a process which writes a lot of data. Binary/ASCII data > p=subprocess.Popen(cmd,stdout=subprocess.PIPE) > > I would like to get cmd's return code so I am doing this, > > def run(cmd): > p=subpro

Re: subprocess pipe

2010-11-15 Thread Nobody
On Sun, 14 Nov 2010 19:47:55 +, Tim Harig wrote: > On 2010-11-14, Camille Harang wrote: >> # pg_dump prompts for password so I inject it in stdin. >> pgsql.stdin.write('MY_PASSWORD' + '\n') > > For security reasons, some programs use direct access to the TTY system > for password entry rathe

Re: subprocess pipe

2010-11-14 Thread Camille Harang
Tim Harig a écrit : > On 2010-11-14, Camille Harang wrote: >> # pg_dump prompts for password so I inject it in stdin. >> pgsql.stdin.write('MY_PASSWORD' + '\n') > > For security reasons, some programs use direct access to the TTY system > for password entry rather then reading from stdin. Most o

Re: subprocess pipe

2010-11-14 Thread Camille Harang
Tim Harig a écrit : > On 2010-11-14, Camille Harang wrote: >> # pg_dump prompts for password so I inject it in stdin. >> pgsql.stdin.write('MY_PASSWORD' + '\n') > > For security reasons, some programs use direct access to the TTY system > for password entry rather then reading from stdin. Most o

Re: subprocess pipe

2010-11-14 Thread Tim Harig
On 2010-11-14, Tim Harig wrote: > On 2010-11-14, Camille Harang wrote: >> # pg_dump prompts for password so I inject it in stdin. >> pgsql.stdin.write('MY_PASSWORD' + '\n') > > For security reasons, some programs use direct access to the TTY system > for password entry rather then reading from st

Re: subprocess pipe

2010-11-14 Thread Tim Harig
On 2010-11-14, Camille Harang wrote: > # pg_dump prompts for password so I inject it in stdin. > pgsql.stdin.write('MY_PASSWORD' + '\n') For security reasons, some programs use direct access to the TTY system for password entry rather then reading from stdin. Most of these programs provide anoth

Re: subprocess pipe

2010-11-14 Thread Camille Harang
Hi Chris, thanks for your reply. Chris Rebert a écrit : > Quoting http://docs.python.org/library/subprocess.html , emphasis mine: > """ > On Unix, with shell=True: [...] If args is a sequence, ***the first > item*** specifies the command string, and any additional items will be > treated as additi

Re: subprocess pipe

2010-11-14 Thread Chris Rebert
On Sun, Nov 14, 2010 at 10:50 AM, Camille Harang wrote: > Hi all, > > I'm having a problem with subprocess.Popen. It seems that its unable to > capture the pg_dump's standard inputs & outputs in a non-shell mode: > > from subprocess import Popen, PIPE > > # fire pg_dump in order to read data from