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

Hi monks, I am using rsh in my perl script to execute some commands on a remote host and get some data.Now the problem is that in case if the remote host is down then my script just hangs at that particular point and I have to do ctrl c and start all over again.I want to know that is there some way or the rsh return type which I can use and with thet help of that I can decide whether i want to use rsh or not. I mean to say that I will take the return value of rsh and depending upon that I will set some flag and use that flag. Can anyone suggest something?plz help

Replies are listed 'Best First'.
Re: using rsh in a perl script
by svenXY (Deacon) on Feb 09, 2006 at 10:40 UTC
    Hi,
    how about ping? Net::Ping could be your module of choice here.
    Regards,
    svenXY
Re: using rsh in a perl script
by svenXY (Deacon) on Feb 09, 2006 at 10:09 UTC
    Hi,
    why don't you just first check if the host is up before calling rsh? That way, you don't need a flag as you don't even need to restart your process.
    Regards,
    svenXY
      Hi thanx for the suggestion but I dont want to log into the remote host and check that whether its up or not.In a way you can say that I am performing some task with my script without logging into the remote host.Is there some command through which I can found that the remote host is up or not?

        But you won't have to log into it to check if the host is up. Your rsh call basically does that and that's not what you want.

        You need to use something like ping to check for a network response before trying to log into the host (via rsh, etc). If pinging the host indicates that it is up then try something like rping to see if the OS is up because I've had many a machine lock up tight yet still respond to pings. This is just an extra measure to ensure that you will get the results you need.