CODE
#!/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); }
OUTPUT
[root@host]# ./mytest.pl
Use of uninitialized value in string eq at ./mytest.pl line 14, <GEN0> line 1
In perl, eq is for strings, == is for numbers, just an FYI!
You are getting the error, because $exit is not defined.
Try this test:
This will ignore non-errors ( $exit is undef ) and will sleep when there is an $exit = 0
Now, why are you trying to trap exit 0 and why are you sleeping when it happens?