Notes on timeout:
#start input of commands in telnet #---------------------------------- $|=1; use Net::Telnet; $telnet=new Net::Telnet; $telnet->port(25); $telnet->open("localhost"); #$telnet->waitfor('/\# $/i'); warn "W220 follows\n"; $telnet->waitfor('/220/i'); $cmd="\n"; $telnet->print($cmd); #@output=$telnet->waitfor('/Press any key to continue \(Q to quit\)/') +; warn "W500 follows\n"; # @output is actually the chars from the mailserver following # code 220 excl. until code 500 incl. @output=$telnet->waitfor('/500/'); warn "Pc - (a 502 SMTP code, I'd assume)\n"; $telnet->print('c'); #virtually press c key #@output2=$telnet->waitfor('/\# $/i'); #push(@output,@output2); warn "O==".join("\n",@output,"")."==\n"; warn "Wtimeout follows\n"; # create a deliberate error for error logging # PJ waitfor will ALWAYS DIE ANYWAY -> USE e.g. eval{} # PJ a failed waitfor dies w/o something of interest in $fault, $? or +$! eval{ warn "1", $fault=$telnet->waitfor('/dfs=l,gdmgll<>ifdgoij$/i'); }; warn "2$?\n"; # unused by waitfor warn "3$!\n"; # unused by waitfor warn "4", do{$fault=$telnet->errmsg},"\n"; # pattern match timed-out $telnet->close; if ($fault ne "") { print "you got an error $fault\n"; }

The output for me annoying a postfix mailer daemon is:

W220 follows W500 follows Pc - (a 502 SMTP code, I'd assume) O== anuurn.compact ESMTP Postfix (Ubuntu) 500 == Wtimeout follows 20 3 4pattern match timed-out you got an error pattern match timed-out

In reply to Re: telnet with keypress and errmsg problem by jakobi
in thread 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.