I have a script that loops through a file of ip addresses and pings them. If the ping is successful, it rsh's to the machine and runs a command. I am using Net-Rsh-0.02. Here is some debug output:
Errno::EADDRINUSE(/usr/local/perl/5.6.1/lib/5.6.1/sun4-solaris/Errno.pm:153):
153: sub EADDRINUSE () { 125 }
DB<1>
Errno::FETCH(/usr/local/perl/5.6.1/lib/5.6.1/sun4-solaris/Errno.pm:182):
182: $errno = 0 unless $! == $errno;
DB<1>
Errno::FETCH(/usr/local/perl/5.6.1/lib/5.6.1/sun4-solaris/Errno.pm:184):
184: return $errno;
DB<1>
Net::Rsh::rsh(/usr/local/perl-v5.6.1/lib/site_perl/5.6.1/Net/Rsh.pm:42):
42: if($!{EADDRINUSE}) {
DB<1>
Carp::croak(/usr/local/perl/5.6.1/lib/5.6.1/Carp.pm:119):
119: sub croak { die shortmess @_ }
DB<1>
Carp::shortmess(/usr/local/perl/5.6.1/lib/5.6.1/Carp.pm:109):
109: { local $@; require Carp::Heavy; } # XXX fix require to not clear $@?
DB<1>
Carp::shortmess(/usr/local/perl/5.6.1/lib/5.6.1/Carp.pm:109):
109: { local $@; require Carp::Heavy; } # XXX fix require to not clear $@?
DB<1>
Carp::shortmess(/usr/local/perl/5.6.1/lib/5.6.1/Carp.pm:109):
109: { local $@; require Carp::Heavy; } # XXX fix require to not clear $@?
DB<1>
Carp::shortmess(/usr/local/perl/5.6.1/lib/5.6.1/Carp/Heavy.pm:247):
247: 1;
Seems like rsh is running out of available ports to use? Here is some code
sub runCommands {
$a=Net::Rsh->new();
$host="$ip";
$local_user="root";
$remote_user="root";
$cmd="/home/admin/master/pushout/scripts/$program";
if ( defined($a) )
{
$status = $a->rsh($host,$local_user,$remote_user,$cmd);
if ( ! defined($status) )
{
$msg = $rsh->errmsg;
print "\t$msg\n";
print LOG "\t$ip\t$msg\n";
$rsh->close;
}
else
{
print PING "$ip $hostname\n";
# Run the program
$a->rsh($host,$local_user,$remote_user,$cmd);
sleep 1;
}
}
else {
print "\t$ip\tConnection refused.\n";
print LOG "\t$ip\tConnection refused.\n";
}
}
Any ideas? It barfs after successfully rsh'ing to 5 hosts.