I am a complete newbie to python, I want to write a program that will open srcds.exe (Source Server) and read it, outputting everything to the console, tried both os and subprocess, nothing helps

import os
import codecs
import subprocess
srcds= subprocess.Popen ("D: \ SteamCMD \ steamapps \ common \ EqRp \ srcds.bat", stdout= subprocess.PIPE, shell= False)
# subprocess.run ("srcds.bat -console")
#With subprocess.Popen ("srcds.bat") as f:
print (str (srcds))

For paths with this slash, use raw strings, since add r before the quotation mark to avoid weird bugs. Added an example in my answer

gil9red2021-10-13 10:21:57

You can work with a batch file, but it is usually better to call the executable file itself with parameters.

Alex Titov2021-10-13 10:27:38