?
=?iso-8859-1?B?aWFuYXLp?=
hey all, I'm trying to get real time updates of batch file output.
Here is my batch file:
@echo off
echo 1
@ping 127.0.0.1 -n 2 -w 1500 > nul
echo 2
@ping 127.0.0.1 -n 2 -w 1500 > nul
echo 3
If I run it in cmd.exe it will print "1", wait 15sec, print "2", wait
15sec, print "3".
I tried doing it like this:
r, w, e = popen2.popen3('"C:/path/to/test.bat"',bufsize=0)
for line in r:
self.display.WriteText(line)
.... but get: ValueError: popen3() arg 3 must be -1
If I use -1, then it waits for the batch file to complete, and prints
out all 3 lines at once.
So I tried subprocess:
proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0,
stdout=subprocess.PIPE)
for line in proc.stdout:
self.display.WriteText(line)
No error message, but no real time printing either.
info:
self.display is a wx.TextCtrl - not that it should matter,as
'WriteText()' behaves basically like 'print'
winXP pro SP2, python 2.5, wxPython 2.6.3.3
You help is appreciated.
Here is my batch file:
@echo off
echo 1
@ping 127.0.0.1 -n 2 -w 1500 > nul
echo 2
@ping 127.0.0.1 -n 2 -w 1500 > nul
echo 3
If I run it in cmd.exe it will print "1", wait 15sec, print "2", wait
15sec, print "3".
I tried doing it like this:
r, w, e = popen2.popen3('"C:/path/to/test.bat"',bufsize=0)
for line in r:
self.display.WriteText(line)
.... but get: ValueError: popen3() arg 3 must be -1
If I use -1, then it waits for the batch file to complete, and prints
out all 3 lines at once.
So I tried subprocess:
proc = subprocess.Popen('"C:/path/to/test.bat"', bufsize=0,
stdout=subprocess.PIPE)
for line in proc.stdout:
self.display.WriteText(line)
No error message, but no real time printing either.
info:
self.display is a wx.TextCtrl - not that it should matter,as
'WriteText()' behaves basically like 'print'
winXP pro SP2, python 2.5, wxPython 2.6.3.3
You help is appreciated.