Tag Archives: Net Telnet

Perl help – how to assign output of perl to variable

By whipuras

Hi, guys, i have a script i inherited from a coworker but i’m not perl savy. The script works but i would like it to work better. I want to run this command

./ciscomgrtest.pl -r “show version” -h hosts.router

and have the script goto each router in the hosts.router file and run the command “show version” on telnet.

Right now the script works but i have to put in the “show version” inside a variable inside the actual script like this.


#!/usr/local/bin/perl
#
#
use Net::Ping;
use Net::Telnet;
use Net::DNS::Resolver;
use Getopt::Std;
use lib '/home/sadmin';
use BER;
use SNMP_Session;

$COMMAND = 'show version';


How can i get that -r switch to put the “show version” from the command line into the variable when run? BTW the -r is arbitray, any switch would work.

hope this makes sense. thanks

…read more
Source: FULL ARTICLE at The UNIX and Linux Forums