I have had the following problem which both Google and the Python documentation cannot aid me.
Essentially, I want to be able to perform redirection at the command-line level using the subprocess library as in the following (using a shell script) so I can perform operations in that directory:
Example:
#!/usr/local/bin/python
from subprocess import call
call("cd", "/usr/local/bin")
However, it doesn’t change to that directory. Does anyone know what I am missing? I will be most appreciative of any insight that anyone can give on this.
Thanks!
The shell started by
subprocess.call()changes directory. And then it exits. Your script does not change directories. Tryos.chdir()instead.