Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Rsh dies with EADDRINUSE

by jgiller (Novice)
on Mar 01, 2007 at 18:32 UTC ( [id://602745]=perlquestion: print w/replies, xml ) Need Help??

jgiller has asked for the wisdom of the Perl Monks concerning the following question:

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.

Replies are listed 'Best First'.
Re: Rsh dies with EADDRINUSE
by Fletch (Bishop) on Mar 01, 2007 at 19:02 UTC

    It's a problem with the r-services protocol itself in that it requires a source port < 1024 (IMSMR). The best solution is to use SSH instead, which doesn't have this limitation and is light years more secure.

Re: Rsh dies with EADDRINUSE
by merlyn (Sage) on Mar 01, 2007 at 19:12 UTC
      rsh seems to be very popular in the large corporate environment. After my first aneurysm, I decided to ignore that word (and all the glorious security concerns that follow) and pretend that the world is a happy, loving place.

        It's popular until you have a wave (wave? gaggle? plague? scourge?) of SOX auditors come through. Then it's persona non grata (much like the auditors . . . :).

      Get out your platform shoes. I know people that use rsh to fire up processes on trusted remote machines this way (e.g. think 1000s of machines connected on a private network). It gets around some authentication overhead, encryption, and having to set things up in something like inetd on each machine (esp if you aren't the admin and politics rule). Sadly, since scaling configuration and performance does become an issue to them, using rsh becomes a very tempting, easy way...
Re: Rsh dies with EADDRINUSE
by jettero (Monsignor) on Mar 01, 2007 at 18:46 UTC
    $a is a poor choice for a variable name there... particularly if you don't lexicalize it with my. $a is special you see. It has to do with sort and globalness...

    In any case, you'd probably benifit from closing the rsh when you're done with it. Oh, dear. I just noticed Net::Rsh uses $a in it's example and doesn't mention a close method. That module may not be any good — I've never tried it, so I couldn't say, but the documentation is giving it a bad name.

    -Paul

Re: Rsh dies with EADDRINUSE
by almut (Canon) on Mar 01, 2007 at 19:51 UTC

    As background info, you might want to read this discussion related to issues with TIME_WAIT and SO_REUSEADDR in scenarios like you seem to be having...   And, if you really, really, REALLY must use something rsh-like for this, you might want to try this guy's implementation (in Perl) of a "multi-rsh" specifically for purposes like these (use at your own risk, though - can't say much about the code quality).

Re: Rsh dies with EADDRINUSE
by perrin (Chancellor) on Mar 02, 2007 at 17:33 UTC
    EADDRINUSE
    Someone nearby is playing DDR, and the jumping is scrambling the bits. Please stop dancing until the rsh script is finished.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://602745]
Approved by jettero
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-19 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found