简体   繁体   English

使用 integer arguments 从 ZA7F5F35426B927411FC9231B5638271 运行 Perl 文件

[英]Run Perl file with integer arguments from a Python script

I am trying to run the Perl script rtpc.pl from a Python script from the command line with two input arguments.我正在尝试从带有两个输入 arguments 的命令行从 Python 脚本运行 Perl 脚本 rtpc.pl。 Normally, I run the Perl script from the command line with two arguments:通常,我使用两个 arguments 从命令行运行 Perl 脚本:

perl rtpc.pl [ARG1] [ARG2]

What I want is a separate python script that I can call from the command line that I can input [ARG1] and [ARG2] into while compiling the Perl script rtpc.pl.我想要的是一个单独的 python 脚本,我可以从命令行调用它,我可以在编译 Perl 脚本 rtpc.pl 时输入 [ARG1] 和 [ARG2]。

Something like:就像是:

python3 pyscript.py 

So far, in my python script, I am using the subprocess module, but I am a little unsure how to pass arguments for my perl script.到目前为止,在我的 python 脚本中,我正在使用子进程模块,但我有点不确定如何为我的 perl 脚本传递 arguments。

pipe = subprocess.Popen(["perl", "rtpc.pl"], stdout=subprocess.PIPE)

How would I input the arguments needed to equivalently run the Perl script terminal command?如何输入等效运行 Perl 脚本终端命令所需的 arguments? I should also mention that the shell that I am using is tcsh.我还应该提到我正在使用的 shell 是 tcsh。

Add them to the list you pass to subprocess.Popen() .将它们添加到您传递给subprocess.Popen()的列表中。

arg1 = 'foo'
arg2 = 'bar'
pipe = subprocess.Popen(["perl", "rtpc.pl", arg1, arg2], stdout=subprocess.PIPE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM