RSH Timeout

Hi All

I have a nice little script that i have written in Perl, in it use RSH ( yes i know it is i should being using ssh, but it i secure network it is being run on) the idea of the script it that it will RSH into a machine and then follow out a command, the problem i am running into is if the RSH deamon for what ever reason as stopped working on the machine, the script will keep trying to accsess the machine for a few mins and then move onto the next, is there a way to add a timeout, so if the connect is not made in say 30 seconds it will move on

thanks

John

I would try to do the following (Im a beginner :wink: ) -

CHK=`ssh2 -q <IP> "ps -ef | grep rshd | grep -v grep"`  

if [ $CHK -eq 0 ]; then
    sleep 30
    CHK=`ssh2 -q <IP> "ps -ef | grep rshd | grep -v grep"`
    
   if [ $CHK -ne 0 ];then
      //call your script here
   else
     //rshd in remote sys is not up
    //do what you want to
   fi
else
  //rshd running - call your script here too
fi

i could be wrong but is that not just using ssh instead to check to make sure rsh is running??

I do not really care that it is not running, i just want the script to pass over that machine and carry on with the other machines in the list.
thanks

John

rsh itself apparently doesn't support a timeout. If you've got netcat available, you could use this

netcat -z -w 3 remote 514

and check $?.
Or use IO::Socket::INET to open a connection yourself with a timeout and check that.