Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#!/usr/bin/perl and i dont have a f"§$k clue

Status
Not open for further replies.

samdaman

Technical User
Oct 23, 2002
23
NZ
Hi anyone out there.

I am a Cisco administrator that has been chucked headfirst into the world of scripting. So starting yesterday, I have made my first script that works. yahooo. Its below if needed

I need this script to open interface dialers on a cisco router. The script below can open a file, and open a dialer via telnet, but only if I enter the router ip address, and dialer number manually. I need to dynamically (meaning automated, no human input) open any router and its associated dialers that might be in this file. The file is dynamically made, and can be split up if necessary.

Help me please, I am trying to work out how to do it now, but it took me the better part of a day to open the file ahhhh. Im using windows

I promise to always blame the network from now on, and NOT the programmers ;-)))

Sam

#!E:\Perl\bin


open (LOGFILE, "log.txt") or die "yes its not working again";


$title = <LOGFILE>;
print &quot;Report Title: $title&quot;;
for $line (<LOGFILE>) {
print $line;
}

use Net::Telnet::Cisco;

my $session = Net::Telnet::Cisco->new(Host

=> '172.24.100.211'); #here is the router address

$session->login('login', 'cisco');
if ($session->enable(cisco)) {
@output = $session->cmd('show privilege');
print &quot;My privileges: @output\n&quot;;
} else {
warn &quot;Cant enable: &quot; . $session->errmsg;
}

my @output = $session->cmd('configure terminal');
my @output = $session->cmd('interface Dialer 101'); #here #is the dialer number

my @output = $session->cmd('No Shutdown');





 
What is the format of log.txt? (i.e. what does an example record look like? Is each ip address/dialer on the same line?)

jaa
 
Its a text file. I guess im not to sure about how I should write that too. At the moment its

Router 172.24.100.111

dialer 1;2;3...

Should I use a spreadsheet instead? or format it differently.

Thanks for you help

Sam
 
So you mean something like?

172.24.100.111 1 2 3 ...
?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top