1
whileループまたはuntilループの中でLinuxシェルコマンドを実行する2つの条件を含める最善の方法を見つけようとしています。Perl:untilループの2つの条件(Linuxシェルコマンドの)を持つ最良の方法
かなり多く、私は次のいずれかの方法を考えることができます。
until ((`who |grep user1`) && (`last -5 |grep user2`)) {
print "Waiting...\n";
sleep(1);
}
または
open(my $command1, "who |"); open(my $command2, "last -5 |");
my $status1=1; my $status2=1;
until (($status1 == 0) && ($status2 == 0)) {
while(<$command1>) { $status1=0 if /user1/; }
while(<$command2>) { $status2=0 if /user2/; }
print "*** Waiting....... \n";
sleep(1);
close($command2); close($command1);
}
私は上記を行うには良いPerlの方法があるかもしれませんね。
ご協力いただければ幸いです。
mob - 優秀!はるかに良く見えて、ありがとう。 – Young