【发布时间】:2015-04-20 11:50:50
【问题描述】:
我尝试通过 Python 2.6 中的 subprocess 模块调用 shellscript。
import subprocess
shellFile = open("linksNetCdf.txt", "r")
for row in shellFile:
subprocess.call([str(row)])
我的文件名长度在 400 到 430 个字符之间。 调用脚本时出现错误:
File "/usr/lib64/python2.6/subprocess.py", line 444, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib64/python2.6/subprocess.py", line 595, in __init__
errread, errwrite)
File "/usr/lib64/python2.6/subprocess.py", line 1106, in _execute_child
raise child_exception
OSError: [Errno 36] File name too long
linksNetCdf.txt 中的行示例是
./ShellScript 'Title' 'Sometehing else' 'InfoInfo' 'MoreInformation' inputfiile outputfile.txt 3 2
任何想法如何仍然运行脚本?
【问题讨论】:
-
你有没有试过弄清楚你的系统上文件名的最大允许长度是多少
getconf NAME_MAX / -
可能会显示
head的 linksNetCdf.txt -
@flazzarini 当我“手动”键入它或从 .txt 复制链接时它可以工作。并将其粘贴到 ssh 安全客户端中...
-
@JoseRicardoBustosM。不,.txt 中没有头,只有 ./..sh ... 命令
-
@Stoffer: 不,他的意思是运行命令
head linksNetCdf.txt,然后向我们展示结果...