Hi Monks!
I have written a small programme to execute "rsh" command with time out option. Here is my code.
use strict; my $NETE_FAILURE = -1; my $NETE_SUCCESS = 0; my $timeout = 10; eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; my $Error = &Rsh("<machinename>","perl <path>s1.pl"); print "Error::$Error\n"; if ($Error == $NETE_FAILURE) { die "Failure\n"; } alarm 0; }; if ($@) { if ($@ eq "alarm\n") { die "TimeOut\n"; } } else { print "Success\n"; } sub Rsh { my($MachineName,$Command,$ErrorText,$Length); if (scalar(@_) != 2) { print ("Error:Wrong number of arguments supplied\n"); return ($NETE_FAILURE); } ($MachineName,$Command)=@_; # Get the machine OS my $OS=$^O; if ($OS=~ m/hpux/i) { $Command = "remsh" . " $MachineName" . " $Command"; } elsif ($OS =~ /MSWin32/i) { $Command = "rsh" . " $MachineName" . " -n $Command"; } else { $Command = "rsh" . " $MachineName" . " $Command"; } #Creating temporary file my $ErrorFile = "RH".$$; my $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:$ErrorText"); close (fhError); unlink ($ErrorFile); return ($NETE_FAILURE); } else { close (fhError); } } unlink ($ErrorFile); if ($Error != 0 ) { print ("Error:Executed command $Command with error return status +\n"); return ($NETE_FAILURE); } return ($NETE_SUCCESS); }
This is running fine in Solaris box but when I am trying to execute in Windows 2000 box then Rsh function within eval block is not executing. Any pointer how can I execute Rsh function in Win2k box?
Thanks in advance.
Regards
-Pijush

In reply to How can I execute "eval" command in WINDOWS 2000? by pijush

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.