in reply to Re: Re^3: Cisco Telnet
in thread Cisco Telnet

I'm basically fishing in the dark here, but maybe the following will work. Note how it's not passing a literal constant to ->cmd() anymore, it passes the (modifiable) elements of an array. It's the only spot I can think of; if that's not it, you probably have to contact the module author.
use strict; use Net::Telnet::Cisco; open my $log, '>', 'logfile' or die "Cannnot open log file : $!\n"; open my $seed, '<', 'seedfile' or die "Cannot open seed file : $!\n"; my @commands =('show line aux 0'); while(<$seed>) { chomp; my $Telnet = Net::Telnet::Cisco->new(Host => $_) or die "Cannot open session to '$_': $!\n"; $Telnet->login(Name => 'user', Password => 'pass') or die "Cannot log into device '$_': $!\n"; print $log "$_\n", $Telnet->cmd($_), @commands; }

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re^5: Cisco Telnet
by CongoGrey (Sexton) on Feb 20, 2003 at 18:35 UTC
    Thanks that was it. You truly are the man, the myth and the legend! Here is the final version i think:
    #Use the Net Telnet Cisco module to getting into routers #Written by Richmon Schumann 2-19-03 #Version 1.2 #Module Declarations ########################################################### use strict; use Net::Telnet::Cisco; ########################################################### #The script will initialize my files #This opens my log file for output # open my $log, '>', 'logfile' or die "Cannnot open log file : $!\n"; # #This opens my seed file and stores it into an array # open my $seed, '<', 'seedfile' or die "Cannot open file : $!\n"; #This stores the contents of the seed file into an array my @commands = ('show line aux 0'); ############################################################ #MAIN SCRIPT #This does the telnet into the routers and logs the output to the logf +ile # while(<$seed>) { chomp; my $Telnet = Net::Telnet::Cisco->new(Host => $_) or die "Cannot op +en session to '$seed': $!\n"; $Telnet->login(Name => 'user', Password => 'pass') or die "Cannot +log into device '$_': $!\n"; print $log "$_\n", grep (/Modem hardware state:/, map $Telnet->cmd +($_), @commands); } ############################################################ #Cleanup close $log; close $seed;