php - Python subprocess doesn't recognize commands in $PATH -
i'm trying debug sublime plugin stopped working of sudden.
i have following code in plugin.
proc = subprocess.popen(cmd, stdin=subprocess.pipe, stdout=subprocess.pipe, stderr=subprocess.stdout, startupinfo=info, cwd=home) data = proc.communicate()[0] basically, it's executing file has #!/usr/bin/env php @ top. when run command, env: php: no such file or directory error message.
i fixed using absolute path.
solution 1: #!/usr/bin/env /applications/mamp/bin/php/php5.5.18/bin/php
while works, wonder why doesn't work when php available when execute in terminal , path command defined in $path variable.
how can fix this?
as in docs need pass shell=true, argument subprocess.popen:
if shell true, specified command executed through shell. can useful if using python enhanced control flow offers on system shells , still want convenient access other shell features such shell pipes, filename wildcards, environment variable expansion, , expansion of ~ user’s home directory.
though use of shell=true discourged due security considerations.
Comments
Post a Comment