I have a folder with multiple scripts that I want to call from Python.
I have added the folder to the PATH to be able to call these from any directory. And it has been added correctly:
user@myuser:~ export PATH=$PATH:~/misScripts
user@myuser:~ bash scriptEcho.sh
Hello world!
But when I try to call this from Python it tells me that the file does not exist.
pi@raspberrypi:~ $ python3
Python 3.5.3
>>> import subprocess
>>> subprocess.run(['bash','scriptEcho.sh'])
bash: scriptEcho.sh: No such file or directory
CompletedProcess(args=['bash', 'scriptEcho.sh'], returncode=127)
If subprocess is added shell = True, the interpreter closes and leaves a hanging process (which does not execute the script anyway).
Any idea why does it tell me that the file does not exist, and how to call the PATH scripts from python?