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:
- "rsh" command itself fails i.e. in the remote Unix box there is no equivalent user or ".rhosts" file.
- During execution of command using "rsh" command any error is occured and I want to analyse this error.
- "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
if ($OS=~ /hpux/i)
$Command = "remsh" . " <MachineName>" . " <Command>";
$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"))
$ErrorText .= $_;
$Length = scalar(split(//,$ErrorText));
if($Length != 0 )
print "Error occured during the execution of rsh command";
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.
Edit, BazB: added formatting and code tags.