0

在字符串下方运行的两个 Popen 命令是相同的,但当我输入在终端中运行的整个命令时,只有第二个命令有效。第一个我可以看到ghostscript命令在弹出时运行,即使使用-q它不应该,但据我所知,输出不会在任何地方生成。第二种情况没有弹出窗口,但它按应有的方式输出到 output.pdf。

在输入中,第一个参数是输出文件的名称,任何先前的参数都是输入的 pdf 文件。

有谁知道发生了什么??

#!/usr/bin/python
from subprocess import Popen, PIPE
import os
import sys
output = sys.argv[1]
cwd = os.getcwd()
cmd = ['gs', '-q', '-dNOPAUSE','-dBATCH', '-sDECIVE=pdfwrite', '-sOutputFile='+str(output)]
for i in range(2,len(sys.argv)): # appends all input pdfs at the end to be arguments
    cmd.append(sys.argv[i])
#a = Popen(cmd) # Done originally but didn't work either
a = Popen(' '.join(cmd), shell=True)
a.wait()
a = Popen('gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf', shell=True)
a.wait()
4

0 回答 0