【发布时间】:2017-05-21 16:23:59
【问题描述】:
我必须通过 python 脚本调用创建一封电子邮件:
subprocess.call([
'thunderbird',
'-compose',
"preselectid='{}',to='{}',cc='{}',subject='{}',body='{}'".format(
preselectid, to, cc, subject, body),
])
但是当body“太大”时,电子邮件会被截断。
我知道在 Windows 上限制为 32,768 个字符 (What is the subprocess.Popen max length of the args parameter?),但我在 Linux 上(使用 zsh)并且在使用
回显字符串时subprocess.call([
'echo',
"preselectid='{}',to='{}',cc='{}',subject='{}',body='{}'".format(
preselectid, to, cc, subject, body),
])
我收到完整且正确的电子邮件内容。
我该如何解决这个问题?
编辑:
感谢@slezica,我发现复制粘贴生成的电子邮件并从命令行运行命令,无论如何,我得到了截断的电子邮件(在 32,303 字符处)。
问题是thunderbird。
【问题讨论】:
-
您遇到错误了吗?如果“thunderbird -compose”和“echo”之间的大小差异跨越某个界限,你能用
echo尝试更大的主体吗? -
尝试从命令行运行调用。这可能是
thunderbird的限制,或者您可能因为thunderbird -compose和echo之间的字符差异而达到了限制 -
@slezica 很好的提示(我很笨),我已经编辑了问题
-
不是解决方案,但运行
getconf ARG_MAX可以获得shell 参数的最大长度。如果echo可以接受,这可能只是thunderbird的限制 -
@slezica:是的,我现在也认为问题出在雷鸟身上。
ARG_MAX的大小为 2097152。
标签: python linux subprocess pipe thunderbird