I wrote the following script called file_I_executed.py:
import subprocess
def main():
loc = subprocess.popen("pwd")
print loc
Which gave the result:
C:\Python27\python.exe C:/Users/username/PycharmProjects/projectname/file_I_executed.py
However, when I try "pwd" on cmd windows, I get:
C:\Users\username\somedirectory>pwd
'pwd' is not recognized as an internal or external command,
operable program or batch file.
What gives? How does the subprocess work? Why does "pwd" give me the python path, as well as the script path, when it obviously should not give me this, when I run this from the Windows command line?
I am using python 2.7.1 from pycharm, on windows 7.
CLARIFICATION: I fully understand that "pwd" is not a Windows command. However, the above script gave me the result that I indicated, and I do not understand why.
source
share