There's probably something wrong with your code, vasanth.easyrider. However, since you have not shown your code that's about all one can say. If you do decide to share the non-capturing code be sure to enclose it in <code> tags and it pays to do the same for any relevant data.

Update: You have edited your post to include the code now. See How do I change/delete my post? for how to mark it so. The code provided doesn't compile, which isn't a great start. It also has use Switch; without further reference to this module. I would remove that if you aren't using it - see Short, Self-Contained, Correct Example for how to present a good piece of sample code.

What is the actual error condition? ie. what do you actually see as output compared to what you expect? Here is an SSCCE to get you started:

#!/usr/bin/env perl use strict; use warnings; use Net::Telnet; my $nt = Net::Telnet->new (Host => 'www.perlmonks.org', Port => 80, Ti +meout => 20); $nt->prompt ('/<\/html>/'); my @output = $nt->cmd ("GET / HTTP/1.1\nHost: www.perlmonks.org\n\n"); print "Here are the HTTP headers:\n\n"; for my $line (@output) { print $line; last if length ($line) < 3; } print "End of headers.\n"; $nt->close; exit;

See how the output is captured and manipulated? How does that differ from your own approach?


In reply to Re: Net::Telnet not capturing output by hippo
in thread Telnet Error - Vasanth by vasanth.easyrider

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.