Get Bash Output With Python
I'm trying to make a simple command that will let me run bash fully in Python, including output strings. This function worked great on systems I use at my job: import subprocess d
Solution 1:
I'm leaving this question up because I think the run()
command above is useful and I couldn't find anything similar on SO.
However, my solution was very system specific. The problem was, I am running this script within Sublime Text 2 and had manually replaced the path in Python.sublime-settings
with
"path":"/Library/Frameworks/Python.framework/Versions/Current/bin/",
I did this because I'd had problems getting ST2 to find the right version of python
. Well, this also overwrites the system-wide PATH variable within ST2, thus blocking my access to simple shell programs like ls
.
Erasing the "path": ...
line from Python.sublime-settings
fixed my problem.
EDIT
As suggested by mklement0, changing the line to append the path works as well:
"path": "$PATH:/Library/Frameworks/Python.framework/Versions/Current/bin/",
Post a Comment for "Get Bash Output With Python"