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.
<代码>python_script.py 援引shell_script.sh
, 采用subprocess. calls()
。
See below:
subprocess.call([ /complete_path/shell_script.sh , param1 , param2 ,
param3 ], shell=True)
当我试图执行字典python_script.py
时,我拒绝批准。
我尝试了不同的方法。
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
)
解决这一问题的最佳途径是什么。
感谢。