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

Popen Question

2010-11-04 Thread moogyd
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 question which is demonstrated below. [sde:st.

Re: a popen question. Please help

2009-08-31 Thread Aahz
In article , Tim Chase wrote: > >Darn "standards" :-/ The wonderful thing about standards is that there are so many to choose from. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ "I support family values -- Addams family values" --www.nancybuttons.com -- http

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

Popen question (redundant processes)

2009-08-30 Thread Sebastian
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_ddr7_allmag_kcor_in_test.dat"], stdout=PIPE ) > p2 = Popen(["fit_coe

Re:a popen question. Please help

2009-08-30 Thread ivanko . rus
First, I think you should use subprocess.Popen (it's recommended by PEP-324) instead of os.popen. For example: p = subprocess.Popen(["top"], stdout = PIPE) p.stdout.readlines() And to write to stdin (in your case "q") you can use p.stdin.write("q"), or terminate the process with p.terminate(

Re: a popen question. Please help

2009-08-30 Thread Tim Chase
os.popen('top -n1').readlines() Hm, interesting. On Mac OS X's (and BSD's?) top, -n instead specifies the number of processes to list at a time (i.e. list only the top N processes), which is entirely different. [reaching over to my Mac] Looks like "top" there supports a -l parameter which do

Re: a popen question. Please help

2009-08-30 Thread Chris Rebert
On Sun, Aug 30, 2009 at 4:43 AM, Tim Chase wrote: >> texts = os.popen('top').readlines() >> print texts >> >> It calls the command line "top" and will print out some texts. >> But first I have to press the keyboard "q" to quit the subprocess "top", >> then the texts will be printed, otherwise it ju

Re: a popen question. Please help

2009-08-30 Thread Tim Chase
texts = os.popen('top').readlines() print texts It calls the command line "top" and will print out some texts. But first I have to press the keyboard "q" to quit the subprocess "top", then the texts will be printed, otherwise it just stands by with blank. Question is. Do you know how to give "q

a popen question. Please help

2009-08-30 Thread Joni Lee
Hi all, I write a small script texts = os.popen('top').readlines() print texts It calls the command line "top" and will print out some texts. But first I have to press the keyboard "q" to quit the subprocess "top", then the texts will be printed, otherwise it just stands by with blank. Questio

Re: newbie: popen question

2009-05-29 Thread Lie Ryan
thebiggestbangthe...@gmail.com wrote: > On May 28, 5:31 am, Sebastian Wiesner wrote: >> >> >>> Your best bet is to make sudo not ask for a password. :) If you >>> don't have the rights, then you can use pexpect to do what you want to >>> do. http://pexpect.sourceforge.net/pexpect.html >>> See

Re: newbie: popen question

2009-05-28 Thread thebiggestbangtheory
On May 28, 5:31 am, Sebastian Wiesner wrote: > > > > Your best bet is to make sudo not ask for a password.  :)  If you > > don't have the rights, then you can use pexpect to do what you want to > > do.  http://pexpect.sourceforge.net/pexpect.html > > > See the second example on that page. > > > c

Re: newbie: popen question

2009-05-28 Thread Sebastian Wiesner
> Your best bet is to make sudo not ask for a password. :) If you > don't have the rights, then you can use pexpect to do what you want to > do. http://pexpect.sourceforge.net/pexpect.html > > See the second example on that page. > > child = pexpect.spawn('scp foo myn...@host.example.com:.')

Re: newbie: popen question

2009-05-28 Thread Jeremiah Dodds
On Thu, May 28, 2009 at 9:11 AM, Sean DiZazzo wrote: > On May 27, 6:10 pm, thebiggestbangthe...@gmail.com wrote: > > hello everyone :-), > > I am a newbie to python. I am trying to run a > > bash script from within a python program. I would greatly appreciate > > any point

Re: newbie: popen question

2009-05-28 Thread Sean DiZazzo
On May 27, 6:10 pm, thebiggestbangthe...@gmail.com wrote: > hello everyone :-), >                          I am a newbie to python. I am trying to run a > bash script from within a python program. I would greatly appreciate > any pointers/comments about how to get around the problem I am facing. >

newbie: popen question

2009-05-27 Thread thebiggestbangtheory
hello everyone :-), I am a newbie to python. I am trying to run a bash script from within a python program. I would greatly appreciate any pointers/comments about how to get around the problem I am facing. I want to run bash script: code.sh from within a python program. c

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

popen question

2008-01-08 Thread Robert Latest
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 line a second, and then quits. I would have expected the python program to spit

Re: maybe a popen question... or something else?

2007-08-06 Thread Steve Holden
dude wrote: > Working on Windows XP > Say I have a Windows executable, foo.exe. > foo.exe is a command line tool that can take a number of different > arguments and perform corresponding actions. > > I want to invoke foo.exe from a Python script (using whatever will > work best). I want to contin

maybe a popen question... or something else?

2007-08-06 Thread dude
Working on Windows XP Say I have a Windows executable, foo.exe. foo.exe is a command line tool that can take a number of different arguments and perform corresponding actions. I want to invoke foo.exe from a Python script (using whatever will work best). I want to continuously pass arguments to f