How To Use Subprocess.popen With Built-in Command On Windows
In my old python script, I use the following code to show the result for Windows cmd command: print(os.popen('dir c:\\').read()) As the python 2.7 document said os.popen is obsole
Solution 1:
You should use call subprocess.Popen
with shell=True
as below:
import subprocess
result = subprocess.Popen("dir c:", shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error = result.communicate()
print (output)
Post a Comment for "How To Use Subprocess.popen With Built-in Command On Windows"