Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Is there any way to implement timeout option with rsh?

by pijush (Scribe)
on Nov 26, 2003 at 14:03 UTC ( #310248=perlquestion: print w/replies, xml ) Need Help??
pijush has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I want to execute a script on a remote UNIX box. Lets say this script will create an user in Oracle server ( which is in Unix box). I want my "rsh" implementation can handle all types of error. I have found out which types of error may arrive. These are:

  1. "rsh" command itself fails i.e. in the remote Unix box there is no equivalent user or ".rhosts" file.
  2. During execution of command using "rsh" command any error is occured and I want to analyse this error.
  3. "rsh" command will wait for a certain time and after that if it can not execute it will proceed further i.e. timeout option with "rsh".
I have written following wrapper code for "rsh" which can handle above mentioned 1 and 2 types of errors.
#Get the machine OS $OS=$^O; if ($OS=~ /hpux/i) { $Command = "remsh" . " <MachineName>" . " <Command>"; } else { $Command = "rsh" . " <MachineName>" . " <Command>"; } #Creating temporary file $ErrorFile = "tmp".$$; $Error = 0xffff & system("($Command 2>$ErrorFile)"); # Open the error file and see if it has some contents if( open (fhError, "< $ErrorFile")) { while (<fhError>) { $ErrorText .= $_; } $Length = scalar(split(//,$ErrorText)); if($Length != 0 ) { print "Error occured during the execution of rsh command"; close (fhError); unlink ($ErrorFile); die "\n"; } else { close (fhError); } } unlink ($ErrorFile); if ($Error != 0 ) { die "Error occured during the execution of rsh command\n"; }

Is there any way to implement time out option?
Any help really appreciated.
Thanks in advance.
Regards
-Pijush

Edit, BazB: added formatting and code tags.

Replies are listed 'Best First'.
Re: Is there any way to implement timeout option with rsh?
by BazB (Priest) on Nov 26, 2003 at 14:11 UTC
    See alarm.

    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://310248]
Approved by BazB
help
Chatterbox?
[ambrus]: Corion: as for that, I talked with schmorp, and looked a bit more at Prima
[ambrus]: Corion: from the docs, it definitely looks like it would be possible to write an AnyEvent driver for it using Prima::File and Prima::Timer.
[ambrus]: (I haven't found an idle event.)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2016-12-08 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (140 votes). Check out past polls.