Hi, All,

I have put together a script that cycles through a list of linux hostnames. If I can first successfully ping a machine, I then check to see if my home directory is mounted on that machine.

I am running into a small problem, though: even though I can ping a system and get good statistics on the connection, sometimes a machine is, well, brain dead and can't do much of anything (read: it needs a swift reboot :-). I therefore need to improve the way in which I check to see if my home directory is mounted. Here is the routine:-

foreach $Host (@MasterMachineIndex) { &ping; # my subroutine to ping system...works fine $Cmd = "rsh $Host uptime"; $Status = `$Cmd`; $CheckHome = ("rsh $Host \"cd $Home\""); $HomeStatus = `$CheckHome 2>&1`; # This captures STDERR and STD +OUT outputs that may or may not manifest... if ($HomeStatus =~ /No such/) { # May need to add more keyw +ords here. Not sure all OSs echo same nomenclature... print ("$Home directory not mounted on $Host! Skipping...\n") +; } else { $CPUScan = "rsh $Host \"CPUScan.pl >> ./foo\""; $CHECK = `$CPUScan`; print ("$Host:\t$Status"); } }

The crux of the problem is the second and third lines ("rsh $Host uptime"): sometimes after a successful ping, this rsh operation just doesn't complete and the foreach just grinds to a halt. I have been trying to add in alarm functionality, but I am failing so miserably I am not even going to post my pathetic code.

Any suggestions? I just want to try to rsh into the system, and if nothing happens within, say, 5 seconds, just move on the next host in the @MasterMachineIndex. If I eliminate known problem workstations from my list, the code above rips along just fine.

I would greatly appreciate any suggestions!

Reagrds,

fiddler42


In reply to Trying to get alarm to work... by fiddler42

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.