I have a .sh script that I call with source the_script.sh
. Calling this regularly is fine. However, I am trying to call it from my python script, through subprocess.Popen
.
Calling it from Popen, I am getting the following errors in the following two scenario calls:
foo = subprocess.Popen("source the_script.sh")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1213, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
>>> foo = subprocess.Popen("source the_script.sh", shell = True)
>>> /bin/sh: source: not found
What gives? Why can't I call "source" from Popen, when I can outside of python?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…