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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Is there any way to implement timeout option with rsh? by pijush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-23 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found