All,

I've set up a script to telnet to a remote system and, via Net::Telnet, and execute a command (the remote system is Windows, if that matters). I have little snippet below:

if((@output = $telnetObj->cmd("$fileAry[$i]"))) { #works ! # if((@output = $telnetObj->cmd(String => "$fileAry[$i]", Timeout => 1 +20))) { # seems to hang after the script completes
Where if I use the 1st 'if' condition it works fine and the command completes within a minute or so and the script returns. But if I use the second 'if' condition the command seems to run but then it just seems to hang and the script doesn't return back until ~1/2 hour later (where as it was 1 minute using the 1st 'if'). Very confusing to me.

$fileAry[$i] is the command that is too be executed. Which is the same in both cases.

So, here's my question, is using the 1st 'if' statement ok or should I use some type of timeout value (in case the command fails to execute, something happens on the networks, etc). I'm not sure of the best practices in this scenario.

Thanks all ...


In reply to Have some questions regarding timeout values when using Net::Telnet by TASdvlper

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.