I know that I can create a new directory with the os module. But I was trying to create a new directory with the subprocess module as follows:
p=subprocess.Popen("mkdir extractions", shell=True)
os.chdir("extractions")
When the script executes, I notice that the directory extractions is created but the next os.chdir call fails saying the directory extractions does not exist. I know that I am missing something in terms of using subprocess that makes the next line unaware of the directory created. Please help!
You probably want to call
p.wait()to wait for the mkdir to complete, before calling os.chdir. Or even better, use(stdout, stderr) = p.communicate(), and check the result.