On 20 Apr, 12:25, t.baetz...@bringe.com (Thomas Bätzler) wrote: > Asterix<lange.gerh...@gmail.com> asked: > > > I've made a little script to capture the output of networking > > devices. > > Everything works fine, until I use the "show tech" command in an Cisco > > device. > > Have you considered using the cmd() method of Net::Telnet? It has the option > to individually set a reply timeout for each command: > > #!/usr/bin/perl-w > > use strict; > use Net::Telnet; > > my $host = '42.42.42.42'; > my $sysname = 'cisco'; > my $login_pw = 'letmein'; > my $enable_pw = 'secret'; > > my $tn = Net::Telnet->new( Host => $host ) ){ > $tn->waitfor( '/word: $/' ); > $tn->cmd( String => $login_pw, Prompt => "/$sysname>\$/" ); > $tn->cmd( String => 'enable', Prompt => '/word: $/' ); > $tn->prompt( "/$sysname#\$/" ); > $tn->cmd( String => $enable_pw ); > $tn->cmd( String => 'terminal length 0' ); > my @data = $tn->cmd( String => 'show tech', Timeout => 60 ); > print @data; > > __END__ > > Works fine for me on a 7206. YMMV. > > HTH, > Thomas
=== Thank you for your response ! I've figured out the problem. It was not a problem regarding TELNET but regarding the flushing of the Buffer (Filehadle, STDOUT): Instead of this printf OUTPUT_FILE "@output\n\n"; I've used print OUTPUT_FILE "@output\n\n"; At the top of the script I also inserted "Autoflush": local $| = 1; # Default is 0 http://perldoc.perl.org/perlvar.html -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/