如何使用python脚本中的多个参数运行perl脚本



我做了一个python代码,必须在PC shell上顺序执行一系列perl命令,问题是我没有意识到要发送这些脚本,我必须添加参数(我有n_params),建议?

示例命令发送perl [file_name.pl] [params]

要在windows CMD上运行这些命令,我使用os和子进程

python代码示例

# command = perl [file_name.pl] [params]
# path = location/of/where/the/pl/file/is/saved
perl_script = subprocess.Popen(["C:\Perl64\bin\perl.exe",path + command], stdout=sys.stdout)
perl_script.communicate()

但是像这样运行脚本,代码让我错了,因为它说它在特定目录

中找不到文件名

Popen()

["C:\Perl64\bin\perl.exe", path + command] 

看起来不正确,因为你写的commandperl [file_name.pl] [params]。而不是尝试:

p = subprocess.Popen(["C:\Perl64\bin\perl.exe", path+"file_name.pl", "param1", "param2", ...])

最新更新