Re: get output of cmd-line command under MS windows
On 2006-02-08, Bernard Lebel <[EMAIL PROTECTED]> wrote: Hi Bernhard, > You should give a go to os.popen( ). Article > 6.1.2 and 6.1.3 in the Python Library doc. > that was good, but on python2.4 subprocess is GREAT! e.g.: pipe = subprocess.Popen(tot, stdout=subprocess.PIPE,\ stderr=subprocess.PIPE, shell=False) message = pipe.stdout.read() error = pipe.stderr.read() thanks all, calmar -- calmar (o_ It rocks: LINUX + Command-Line-Interface //\ V_/_ http://www.calmar.ws -- http://mail.python.org/mailman/listinfo/python-list
Re: get output of cmd-line command under MS windows
"calmar" wrote: > that was good, but on python2.4 > > subprocess is GREAT! e.g.: > > pipe = subprocess.Popen(tot, stdout=subprocess.PIPE,\ > stderr=subprocess.PIPE, shell=False) > message = pipe.stdout.read() > error = pipe.stderr.read() footnote: subprocess is available for Python 2.2 and later, from http://www.lysator.liu.se/~astrand/popen5/ -- http://mail.python.org/mailman/listinfo/python-list
Re: get output of cmd-line command under MS windows
On 2006-02-08, Bernard Lebel <[EMAIL PROTECTED]> wrote: Hi Bernhard and all, > oPipe = os.popen( "run C:/program files/my app/executable.exe" ) > > while 1: > sLine = oPipe.read() > print sLine > if sLine == '': > print 'No more line from pipe, exit.' > break > I see. I saw also os.popen("").read() or so. Anyway, not sure if that would also catch stderr? But doesn't matter. It seems, imagemagick (binaries) won't provide proper error-codes, but at least when it prints something, something was not ok probably. I will check the resulting file, to see if everything went ok, and try to catch the output like you mentioned. thanks a lot marco -- calmar (o_ It rocks: LINUX + Command-Line-Interface //\ V_/_ http://www.calmar.ws -- http://mail.python.org/mailman/listinfo/python-list
Re: get output of cmd-line command under MS windows
In article <[EMAIL PROTECTED]>, Bernard Lebel <[EMAIL PROTECTED]> wrote: >You should give a go to os.popen( ). Article >6.1.2 and 6.1.3 in the Python Library doc. > >I recently wrote a program that would create a pipe using the popen() >method, and would enter a while loop. At each iteration, it would read >one line of the pipe output, and the loop would break when it gets an >empty line (indicating the running application is not running in this >case). > >Example: > >import os > >oPipe = os.popen( "run C:/program files/my app/executable.exe" ) > >while 1: > sLine = oPipe.read() > print sLine > if sLine == '': > print 'No more line from pipe, exit.' > break . . . If I understand you correctly, this presentation depends on executable.exe not emitting any blank lines. Some legitimate command-line executables *do* have occasion to put out blank lines, though ... -- http://mail.python.org/mailman/listinfo/python-list
Re: get output of cmd-line command under MS windows
You should give a go to os.popen( ). Article 6.1.2 and 6.1.3 in the Python Library doc. I recently wrote a program that would create a pipe using the popen() method, and would enter a while loop. At each iteration, it would read one line of the pipe output, and the loop would break when it gets an empty line (indicating the running application is not running in this case). Example: import os oPipe = os.popen( "run C:/program files/my app/executable.exe" ) while 1: sLine = oPipe.read() print sLine if sLine == '': print 'No more line from pipe, exit.' break Cheers Bernard On 2/8/06, calmar <[EMAIL PROTECTED]> wrote: > Hi all, > > unfotunately, 'commands.getstatusoutput(command)' does not work under > windows. > > Would there be any alternative? > > os.system also just provides the exit number I think. > > thanks a lot, > and cheers > marco > > > -- > calmar > > (o_ It rocks: LINUX + Command-Line-Interface > //\ > V_/_ http://www.calmar.ws > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list
get output of cmd-line command under MS windows
Hi all, unfotunately, 'commands.getstatusoutput(command)' does not work under windows. Would there be any alternative? os.system also just provides the exit number I think. thanks a lot, and cheers marco -- calmar (o_ It rocks: LINUX + Command-Line-Interface //\ V_/_ http://www.calmar.ws -- http://mail.python.org/mailman/listinfo/python-list