1
我试着从我的Python调用的shell脚本参数,但参数没有被传递Python的子POPEN传递参数
我的shell:
echo "Inside shell"
echo $0
echo $1
cd $1
pwd
for file in *.csv
do
split -l 50000 -d -a 4 "$file" "$file"
done
echo "Outside shell"
与壳=真
this_dir = os.path.dirname(os.path.abspath(__file__))
cmd = [os.path.join(this_dir,'split.sh'),fileslocation]
print 'cmd = ', cmd
process = subprocess.Popen(cmd,shell=True)
参数未正确传递...
with Shell = True删除
cmd = ['/opt/sw/p3/src/PricesPaidAPI/split.sh', '../cookedData']
Traceback (most recent call last):
File "csv_rename.py", line 23, in <module>
process = subprocess.Popen(cmd)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
[Python raise child \ _exception OSError:\ [Errno 8 \] Exec format error]的可能重复(http://stackoverflow.com/questions/16925909/python-raise-child-exception-oserror-errno-8 -exec-format-error)(你的shell脚本缺少shebang ...) – geoffspear
@Wooble我不会说你提供的链接回答这个问题。它清楚地表明OP必须重新编译他的程序,而且它不是一个脚本。 Shebang只是一个没有得到证实的建议。虽然它可能是对的。 – luk32
接受的答案给出了导致OP错误的两种可能性,并且从他在问题中粘贴的脚本中,您可以看到没有shebang线。 – geoffspear