Python run subprocess from parent directory
Solution 1:
I would recommend to use absolute path computed from your python script's path.
import os
source = os.path.dirname(__file__)
parent = os.path.join(source, '../')
script_path = os.path.join(parent, 'a.sh')
script_path
would be absolute path to your script and would be computed from your python script's path, so if your bash script is always at the same relative path from your python script, it will always works, whatever the directory you are running program from.
Btw, I advise to always use os.path.join
to compute paths and never concat strings with +
but use format
. I let you check why.