0

我们有一个交互式脚本(脚本 1),它要求一个 IP 地址并继续它的执行过程。从 script2 调用脚本 1。由于我们知道我们想要将 IP 自动传递给脚本的 IP 地址,因此不需要手动干预

我查看了期望模块。但我无法在 PRODUCTION 服务器中安装该模块。

有人可以建议一种方法来克服这个问题。

4

1 回答 1

0

尝试这个,

#script2.pl

use strict;
use warnings;

use Getopt::Long;

GetOptions (
"ipAddress=s" => \$ip,
) or die("Enter IP address");

my $cmd = "perl script1.pl --ip=$ip";
system($cmd);

.

#script1.pl

use strict;
use warnings;

use Getopt::Long;
GetOptions (
"ip=s" => \$ip,
) or die("Enter IP address");

print "IP address is $ip";

像这样执行。

perl script2.pl --ipAddress=10.11.12.13

如果要直接执行script1,可以这样执行,

perl script1.pl --ip=10.11.12.13
于 2017-05-18T07:42:43.400 回答