0
私は以下に述べるようなスクリプトを持っていますが、「実行する必要のあるコマンド」(forループ内)というコマンドがある時間実行され、 forkしてコマンドを実行すると、 "実行する必要のあるコマンド"(forループ内)のスクリプトの一部だけが実行されます。代わりに、私は "実行する必要のあるコマンド"(forループ)がすべて並列に実行されるようにします。つまり、forループが50回繰り返し実行される場合、50種類のプロセスを並列に実行する必要があり、の間に。ある人がこれをお勧めしますか?perlで並列に実行されるコマンドが必要です
#!/usr/bin/perl
use Expect;
sub hostuser_expect() {
$expect= Expect->new;
$expect->raw_pty(1);
$expect->spawn($cmd)
or die "Cannot spawn $cmd: $!\n";
$expect->expect($timeout,
[ qr/.*\?/i, #/
sub {
my $self = shift;
$self->send("yes\r\n");
exp_continue;
}
]);
$expect->expect($timeout,
[ qr/password:/i, #/
sub {
my $self = shift;
$self->send("$password\n");
exp_continue;
}
]);
#$expect->expect(1500,'-re', 'Mails marked as moved successfully\.$');
#$expect->hard_close();
}
$timeout = 5;
$password = "changeme";
for ($i=1;$i<=50;$i++) {
$cmd="Command which needs to be run";
print "Invoking script - $cmd\n";
hostuser_expect();
sleep(30);
}
これは多くのことを助けた、ありがとう! –