|
Posted by DJ Stunks on April 27, 2006, 8:41 pm
Please log in for more thread options
kishore.konjeti@gmail.com wrote:
> yes i am getting output of telnet in debug folder by specifiying in
> input_log parameter while telnet object construction. It is showing
> correctly.. but i am not able to print using print @lines.
> the code is i have written like this
> use warnings;
> use Net::Telnet;
> my $dumplog = "dumplog.txt";
> my $outputlog = "outputlog.txt";
> my $inputlog="inputlog.txt";
> # instantiate a new CGI object
> my $telnet = new Net::Telnet(Timeout => 10,
> Errmode => 'die',
> Dump_Log => "$dumplog",
> output_log => "$outputlog",
> input_log=>"$inputlog",
>
> );
> # perform a single print statement, with liberal use of the perl
> # string concatenator "." and some CGI methods
>
> $telnet->open("server");
> $telnet->waitfor('/login: $/i');
> #$telnet->output_record_separator("\n");
> $telnet->print("ixlourd") ;
> $telnet->waitfor('/password: $/i');
> $telnet->print("qwest1") ;
>
> $telnet->waitfor('/ixlourd\@e2epia2: $/') ;
>
>
> print "Before ls\n";
>
>
> @lines= $telnet->cmd("banner KISHORE");
> sleep(5);
>
> print @lines; # here i am getting timed out error.
How can you be trying to use a module without reading the
documentation?
if you prompt is really 'ixlourd@e2epia2: ' then the default Prompt
won't work ((care of the documentation I know that The default Prompt
is '/[$%#>] $/')), so how do you expect cmd() to know when it's done
getting input?? It sits there waiting to see something it recognizes
until it times out.
Here's how I usually approach this kind of problem:
1) read module documentation
2) write script with frequent reference to module documentation and
examples therein
3) run script
4) when (not if) script does not do what I expected, re-read
documentation and debug
You may want to consider a similar approach.
-jp
|