使用Python和Django运行.sh
脚本时出现错误。错误如下。
Traceback (most recent call last):
File "cell.py", line 3, in <module>
subprocess.call(shlex.split('./test.sh param1 param2'))
File "/usr/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied
我正在解释下面的代码。
cell.py:
import subprocess
import shlex
param1='Reactor1'
param2='Running'
subprocess.call(shlex.split('bash test.sh',param1,param2))
test.sh:
#!/bin/sh
echo $1
echo $2
exit 0
当我运行该文件时,我收到上述错误。请帮我解决这个错误。
答案 0 :(得分:0)
替换
subprocess.call(shlex.split('bash test.sh',param1,param2))
要
subprocess.call(shlex.split('bash test1.sh %s %s'%(param1,param2)))
或
subprocess.call(['bash', 'test1.sh', param1, param2])