in reply to Telnet Error - Vasanth
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Net::Telnet not capturing output
by vasanth.easyrider (Acolyte) on Feb 23, 2018 at 09:12 UTC |