Python's subprocess: How do I hide the terminal window and still capture the output? -
this code works, terminal window pops (briefly):
print 'trying wireless' while true: wlan = subprocess.popen("netsh wlan connect name='bsd'", stdout = subprocess.pipe, stderr = subprocess.pipe) out, error = wlan.communicate() if out.find('success') >=0: break print "still trying wireless..." time.sleep(0.5) print "connected!"
this python 2.7 on windows 7.
any way stop pop-up , keep grabbing output?
thanks, nick.
i don't have setup this, since there no answers found vaguely promising in docs. can try this:
si = subprocess.startupinfo() si.dwflags = subprocess.startf_useshowwindow # tell windows use wshowwindow options si.wshowwindow = subprocess.sw_hide # showwindow option - 1 sounded useful wlan = subprocess.popen(...., startupinfo=si) # before add startupinfo argument
Comments
Post a Comment