在python中使用subprocess.Popen运行脚本时出现权限错误
我见过一个有线场景,它使用python中的在python中使用subprocess.Popen运行脚本时出现权限错误,python,subprocess,Python,Subprocess,我见过一个有线场景,它使用python中的subprocess.Popen运行shell脚本。如果一个脚本与子进程运行相同的脚本,请检查\u output,它工作正常。 脚本的sdeudo代码可以如下所示: cut -d, -fl filepath | sed 'sedkey' >> otherfilepath 当我使用subprocess.Popen sed: preserving permissions for ‘xxxxxx’: Operation not permitted
subprocess.Popen
运行shell脚本。如果一个脚本与子进程运行相同的脚本,请检查\u output
,它工作正常。
脚本的sdeudo代码可以如下所示:
cut -d, -fl filepath | sed 'sedkey' >> otherfilepath
当我使用subprocess.Popen
sed: preserving permissions for ‘xxxxxx’: Operation not permitted
otherfilepath: Permission denied
process = subprocess.Popen(cmd.split(), stderr=subprocess.PIPE, encoding='utf8')
output, errors = process.communicate(timeout=3600) -The script could take a long time
我对这两个选项都使用以下参数:
subprocess.Popen
sed: preserving permissions for ‘xxxxxx’: Operation not permitted otherfilepath: Permission denied
process = subprocess.Popen(cmd.split(), stderr=subprocess.PIPE, encoding='utf8') output, errors = process.communicate(timeout=3600) -The script could take a long time
:子流程。检查\u输出
output = subprocess.check_output(cmd.split(), stderr=subprocess.PIPE, encoding='utf8')
子流程.check_output
工作正常,另一个选项抛出我提到的错误