Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python's subprocess.Popen() and source

Tags:

python

bash

A third-party Python 2.5 script I'm trying to debug has got me stymied. The relevant part of the script is:

       proc = subprocess.Popen(
               "ls && source houdini_setup",
               shell = True,
               executable = "/bin/bash",
               )

There is a daemon that listens to port 5001 and runs the above script. When the script runs, it fails with the following error:

_cygwin.py
houdini_setup
... (more files) ...
/bin/sh: line 0: source: houdini_setup: file not found

There very much exists a file houdini_setup, as illustrated by the ls, and in fact if I change "source" to "cat" in the script above, the script prints the contents of houdini_setup as expected. Moreover, running the exact above command in a bona-fide bash shell also sources the file with no complaints.

Does anyone have any idea what's going on here?

like image 217
user168715 Avatar asked Jan 22 '23 19:01

user168715


1 Answers

source uses $PATH to find what you pass to it, if you don't specify a directory. Try source ./houdini_setup.

like image 160
Ignacio Vazquez-Abrams Avatar answered Jan 31 '23 16:01

Ignacio Vazquez-Abrams