#!/usr/bin/perl -w
use strict;
use warnings;
use Net::SSH::Perl;
my $ssh_to="10.1.1.9";
my @KEYFILE = ("/home/nagios/.ssh/id_dsa.pub");
my $local="10.1.1.5";
my $vip_ip="10.1.1.50:80";
my $remove = "/usr/bin/sudo /sbin/ipvsadm -e -t $vip_ip -r $local -w 0";
my $ssh = Net::SSH::Perl->new($ssh_to, identity_files=>\@KEYFILE);
my ($stdout, $stderr, $exit) = $ssh->cmd($remove);
if ($exit eq 0) { sleep(300); }
輸出
[[email protected]]# ./mytest.pl
Use of uninitialized value in string eq at ./mytest.pl line 14, <GEN0> line 1
請發佈您實際運行的代碼,或顯示您實際發佈的代碼的輸出。 – ikegami
if語句的目標是如果退出0,如果不是,則死亡5分鐘 – erics
這是我運行的實際代碼 – erics