One answer to your question would be relevant if you were running your script on a UNIX (or UNIX-like) box, trying to connect to WinNT machines, rather than on a WinNT machine itself.

On a UNIX-like machine you could set up a SIGALRM handler in your perl script and use alarm() to set the timer. To paraphrase perlfunc:alarm:

eval { local $SIG{ALRM} = sub { die "alarm\n"; } alarm 10 # here you call your get_sp() subroutine $servicpack = get_sp($computer); alarm 0; }; if ($@) { die unless $@ eq "alarm"; # propagate uexpected errors # timed out } else { # worked }

AFAIK, Perl's signal handling is iffy at best on WinNT machines (at least with ActiveState's port), so you may have to come up with another approach if your script is running on one of those. (I'd try it anyway :)

dmm

You can give a man a fish and feed him for a day ...
Or, you can
teach him to fish and feed him for a lifetime

In reply to Re: Dealing with timeouts using the Shell module by dmmiller2k
in thread Dealing with timeouts using the Shell module by thunders

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.