无法从python子进程执行shell脚本:权限被拒绝

Qua*_*Liu 20 python shell

尝试谷歌搜索但找不到与我的特定问题有关的东西.我正在尝试从python运行shell脚本,但由于权限被拒绝错误,shell脚本无法运行.我正在运行的python代码是:

process = subprocess.Popen('run.sh', shell=True, stdout=subprocess.PIPE)
process.wait()
....
os.killpg(pro.pid, signal.SIGTERM)
Run Code Online (Sandbox Code Playgroud)

我得到的错误:

python RunScript.py "input"
/bin/sh: 1: run.sh: Permission denied
Run Code Online (Sandbox Code Playgroud)

我的shell脚本的内容是:

#!/bin/sh
abspath=$(cd "$(dirname "$0")"; pwd)
CLASSPATH=$CLASSPATH:$abspath/"lib/*":$abspath/"bin"
export CLASSPATH
java -classpath $CLASSPATH my.folder.path.Class $abspath/../data/data.txt $abspath/../data/data2.txt
Run Code Online (Sandbox Code Playgroud)

提前致谢.

Pas*_*eBT 24

检查run.sh模式,如果没有可执行标志,请使用命令设置它

chmod +x run.sh
Run Code Online (Sandbox Code Playgroud)