Re: Popen Question

2010-11-08 Thread Ian
On Nov 8, 3:35 pm, Hans Mulder wrote: > > Perhaps this example better demonstrates what is going on: > > p = subprocess.Popen(['echo one $0 three $1 five', 'two', 'four'], > > ...                      shell=True) > > one two three four five > > Maybe I'm thick, but I still don't understand.  

Re: Popen Question

2010-11-08 Thread Lawrence D'Oliveiro
In message <4cd87b24$0$81481$e4fe5...@news.xs4all.nl>, Hans Mulder wrote: > But in this case the first positional argument is in $0. That’s what confused me. -- http://mail.python.org/mailman/listinfo/python-list

Re: Popen Question

2010-11-08 Thread Hans Mulder
Ian wrote: On Nov 8, 2:43 am, m...@distorted.org.uk (Mark Wooding) wrote: I don’t know what happens to the extra arguments, but they just seem to be ignored if -c is specified. The argument to -c is taken as a shell script; the remaining arguments are made available as positional parameters to

Re: Popen Question

2010-11-08 Thread Ian
On Nov 8, 2:43 am, m...@distorted.org.uk (Mark Wooding) wrote: > > I don’t know what happens to the extra arguments, but they just seem > > to be ignored if -c is specified. > > The argument to -c is taken as a shell script; the remaining arguments > are made available as positional parameters to t

Re: Popen Question

2010-11-08 Thread Mark Wooding
Lawrence D'Oliveiro writes: > In message , Chris Torek wrote: > > > ['/bin/sh', '-c', 'echo', '$MYVAR'] > > > > (with arguments expressed as a Python list). /bin/sh takes the > > string after '-c' as a command, and the remaining argument(s) if > > any are assigned to positional parameters (

Re: Popen Question

2010-11-08 Thread Lawrence D'Oliveiro
In message , Chris Torek wrote: > ['/bin/sh', '-c', 'echo', '$MYVAR'] > > (with arguments expressed as a Python list). /bin/sh takes the > string after '-c' as a command, and the remaining argument(s) if > any are assigned to positional parameters ($0, $1, etc). Doesn’t work. I don’t know w

Re: Popen Question

2010-11-07 Thread moogyd
Hi, Thanks everyone for the replies - it is now clearer. Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Popen Question

2010-11-05 Thread Chris Torek
In article <891a9a80-c30d-4415-ac81-bddd0b564...@g13g2000yqj.googlegroups.com> moogyd wrote: >[sde:st...@lbux03 ~]$ python >Python 2.6 (r26:66714, Feb 21 2009, 02:16:04) >[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2 >Type "help", "copyright", "credits" or "license" for more information.

Re: Popen Question

2010-11-04 Thread Alain Ketterlin
moogyd writes: import os, subprocess os.environ['MYVAR'] = "myval" p = subprocess.Popen(['echo', '$MYVAR'],shell=True) p = subprocess.Popen(['echo', '$MYVAR']) $MYVAR > p = subprocess.Popen('echo $MYVAR',shell=True) myval > p = subprocess.Popen('echo $

Re: Popen Question

2010-11-04 Thread Ravi
On Nov 4, 7:06 pm, moogyd wrote: > Hi, > I usually use csh for my simulation control scripts, but these scripts > are becoming more complex, so I plan to use python for the next > project. > To this end, I am looking at subprocess.Popen() to actually call the > simulations, and have a very basic q

Re: Popen question (redundant processes)

2009-08-30 Thread Gabriel Genellina
En Sun, 30 Aug 2009 17:25:40 -0300, Chris Rebert escribió: On Sun, Aug 30, 2009 at 12:33 PM, Sebastian wrote: Hello World! This is my first post on the list and I'm hoping it is the right forum and not OT, I've searched a bit on this, but, none-the-wiser! My question is on the Popen meth

Re: Popen question (redundant processes)

2009-08-30 Thread Chris Rebert
On Sun, Aug 30, 2009 at 12:33 PM, Sebastian wrote: > Hello World! > This is my first post on the list and I'm hoping it is the right forum and > not OT, I've searched > a bit on this, but, none-the-wiser! > > My question is on the Popen method, here is my snippet: > >> p1 = Popen(["cat", "georgi_dd

Re: popen question

2008-01-08 Thread Karthik Gurusamy
On Jan 8, 1:20 am, Robert Latest <[EMAIL PROTECTED]> wrote: > Hello, > > look at this function: > > -- > def test(): > child = os.popen('./slow') > for line in child: > print line > - > > The program "slow" just writes the numbers 0 through 9 on stdout, one l

Re: popen question

2008-01-08 Thread Hrvoje Niksic
Robert Latest <[EMAIL PROTECTED]> writes: >> If you see lines one by one, you are in luck, and you can fix things >> on the Python level simply by avoiding buffering in popen. If not, >> you will need to resort to more advanced hackery (e.g. fixing stdio >> using LD_PRELOAD). > > Do I really? Aft

(SOLVED) Re: popen question

2008-01-08 Thread Robert Latest
pexpect is the solution. Seems to wrap quite a bit of dirty pseudo-tty hacking. robert -- http://mail.python.org/mailman/listinfo/python-list

Re: popen question

2008-01-08 Thread Robert Latest
Hrvoje Niksic wrote: > stdio uses different buffering strategies depending on the output > type. When the output is a TTY, line buffering is used; when the > output goes to a pipe or file, it is fully buffered. Makes sense. > If you see lines one by one, you are in luck, and you can fix things

Re: popen question

2008-01-08 Thread Hrvoje Niksic
Robert Latest <[EMAIL PROTECTED]> writes: > If 'slow' or some other program does buffered output, how come I can > see its output line-by-line in the shell? stdio uses different buffering strategies depending on the output type. When the output is a TTY, line buffering is used; when the output g

Re: popen question

2008-01-08 Thread Robert Latest
Marc 'BlackJack' Rintsch wrote: > Both processes have to make their communication ends unbuffered or line > buffered. Yeah, I figured something like that. > And do whatever is needed to output the numbers from ``slow`` > unbuffered or line buffered. Hm, "slow" of course is just a little test pr

Re: popen question

2008-01-08 Thread Marc 'BlackJack' Rintsch
On Tue, 08 Jan 2008 09:20:16 +, Robert Latest wrote: > The program "slow" just writes the numbers 0 through 9 on stdout, one line a > second, and then quits. > > I would have expected the python program to spit out a numbers one by one, > instead I see nothing for 10 seconds and then the wh