I'm trying to invoke a shell script shell_script.sh
from a python script (python_script.py
) using the call command. The shell_script.sh
invokes a executable that requires root access to execute.
The python_script.py
invokes shell_script.sh
using subprocess.call()
.
See below:
subprocess.call(['/complete_path/shell_script.sh', 'param1', 'param2',
'param3'], shell=True)
When I try to execute the python script python_script.py
it gives me permission denied.
I've tried different ways.
a) Invoke python with sudo - sudo python python_script.py
b) Invoke sudo into inside the call method - subprocess.call(['sudo' '/complete_path/shell_script.sh', 'param1', 'param2',
'param3'], shell=True
)
What's the best way to resolve this.
Thanks.