Hi,
I'm trying to do something quite simple with Net:Telnet. I'm trying to log into a router, do a 'sh run' (or some other command) and print it to a file. Dead easy, right? I wish. Ok, here's what the code looks like:
#!/usr/bin/perl -w use Net::Telnet; use strict; my $router = "212.31.213.106"; my $t=new Net::Telnet(); my $instr = "sh ver"; $t->open($router); #...does login stuff here...# $t->cmd("term len 0"); $t->cmd("sh run"); my @config = $t->cmd($instr); $t->cmd(" "); my $file = "/home/me/logs/blah"; open(FILE, ">$file"); print FILE "@config";
Now, the weirdness begins. See how I've got 'sh run' as a straight command, then '@config = $t->cmd("$instr")'? Well when I print @config to the file down the bottom, it prints the output of the 'sh run'. And if I change the command before from 'sh run' to something else, it does that. NEVER 'sh ver'. If I remove the command in the 'sh run' line, the @config array remains undefined.
HELP!
In reply to Net::Telnet variable assignment wacky by bonoboy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |