get output of cmd-line command under MS windows

Cameron Laird claird at lairds.us
Thu Feb 9 17:08:03 EST 2006


In article <mailman.1598.1139411970.27775.python-list at python.org>,
Bernard Lebel  <3dbernard at gmail.com> wrote:
>You should give a go to os.popen( <system command here> ). 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 
...



More information about the Python-list mailing list