I'm trying to pipe the output of a simple .bat script to my python script using the following code (Win10 btw):
import subprocess
p = subprocess.Popen(C:UsersPublicgamess-64get-version-names.bat), stdout=subprocess.PIPE)
output = p.communicate()
print(output)
The problem is that the script looks like this:
::
:: Mar 08, 2015 :: Sarom Leang :: get-version-names.bat
::
:: Looks in current directory for gamess.*.exe and outputs the
:: version names to be used in 'rungms.bat' or 'rungms-serial.bat'
::
@setlocal enabledelayedexpansion
@echo ------ -------
@echo Binary Version
@echo ====== =======
@echo.
@for %%f in (gamess.*.exe) do @(
@set temp=%%~nf
@set version=!temp:gamess.=!
@echo %%f !version!)
@echo.
@pause
The @pause
prevents my py script from getting past subprocess.pOpen()
so I wanted to know how to get the stdout
without my script being stopped in it's tracks (And without just deleting the @pause).
question from:
https://stackoverflow.com/questions/65945793/pause-in-bat-file-prevents-subprocess-popen-from-finishing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…