Hi guys, i have a problem with the following code:
#start input of commands in telnet #---------------------------------- $telnet->waitfor('/\# $/i'); $telnet->print($cmd); @output=$telnet->waitfor('/Press any key to continue \(Q to quit\)/'); + $telnet->print('c'); #virtually press c key @output2=$telnet->waitfor('/\# $/i'); push(@output,@output2); $telnet->waitfor('/dfs=l,gdmgll<>ifdgoij$/i'); #creates a deliberate e +rror for error logging $fault=$telnet->errmsg; $telnet->close; if ($fault!="") { print "you got an error; }
Basically i don't want to make several outputs for the displaying of the commands of a switch we have, for now for every "press a key" I need to attach a new array to the older one, is there any way around this? I found out if I try a prompt and do the things manually it also asks a keypress for the next page, but not if i make the prompt screen larger. Perhaps there's a way to incorperate this in the telnet command or something? Also i want do an action if i get an error from the telnet command, the above code doesn't work if i do a $fault is not empty it still skips it, even when i print $fault it says: 'pattern match timed-out' (as it should be) however, i never get to the code with the check if $fault is empty Any suggestions? As i am new to the perl language they will be highly noted. Thanks in advance

In reply to telnet with keypress and errmsg problem by wro

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.