[英]Getting error while doing subprocess call using Python and Django
I am getting some error while running the .sh
script using Python and Django. 使用Python和Django运行.sh
脚本时出现错误。 The errors are given below. 错误在下面给出。
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
I am explaining my code below. 我在下面解释我的代码。
cell.py: cell.py:
import subprocess
import shlex
param1='Reactor1'
param2='Running'
subprocess.call(shlex.split('bash test.sh',param1,param2))
test.sh: test.sh:
#!/bin/sh
echo $1
echo $2
exit 0
While I was running the file I am getting the above error. 在运行文件时,出现上述错误。 Please help me to resolve this error. 请帮助我解决此错误。
Replace your 更换您的
subprocess.call(shlex.split('bash test.sh',param1,param2))
To 至
subprocess.call(shlex.split('bash test1.sh %s %s'%(param1,param2)))
or 要么
subprocess.call(['bash', 'test1.sh', param1, param2])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.