Click to See Complete Forum and Search --> : Script to Login to a Cisco router + execute a command


morgb
10-22-2002, 08:55 AM
Hi Folks,

Firstly I have no experiance in scripting at all :(


I need a script that will allow me to Login to a cisco router :-


- Telnet "IP Adress" enter

- I then need to present a "username" enter

- I then need to present a "password" enter

- After this I need to enter enable mode "enable" enter
-
I now need to isssue a command "clear nat *" enter

- Then exit the router with "quit" enter


Sounds simple, although I dont know any way of storing the above variables

any help would be appreciated.


Cheers. :D

EscapeCharacter
10-22-2002, 04:03 PM
the simplest solution to this would be to use expect (http://www.raycosoft.com/rayco/support/expect_tutor.html#expect)

inkedmn
10-24-2002, 02:50 PM
you could do something like this (this is python, btw)

NOTE: i haven't tested this or anything, this is just to give you an idea:


import telnetlib

username = "your username here"
password = "your password here"
routerIP = "router's IP"

t = telnetlib.Telnet()
t.open(routerIP)
t.write(username)
t.write(password)
t.write("enable")
t.write("clear nat *")
t.write("quit")
t.close()

furrycat
10-25-2002, 01:46 AM
There exist Perl modules to connect to and control Cisco gear.