Running commands on cisco routers using python

Floris Bruynooghe floris.bruynooghe at gmail.com
Tue May 20 08:43:48 EDT 2008


On May 19, 4:18 pm, SPJ <mail2... at yahoo.com> wrote:
> Is it possible to run specific commands on cisco router using Python?
> I have to run command "show access-list" on few hundred cisco routers
> and get the dump into a file. Please let me know if it is feasible and
> the best way to achieve this.

There's no way I'd think about doing this in python.  The best tool
for the task is just shell IMHO:

flub at signy:~$ ssh mercury show access-lists
Welcome to mercury
root at mercury's password:

Standard IP access list 1
    10 permit any (265350 matches)
Standard IP access list 23
    10 permit 192.168.2.0, wildcard bits 0.0.0.255 (2 matches)
Extended IP access list 100
    10 deny ip any 192.168.0.0 0.0.255.255 log-input (8576 matches)
    20 permit ip any any (743438 matches)Connection to mercury closed
by remote host.
flub at signy:~$

You could plug in expect to solve the password thing.  Search for "ssh
expect" for that (and ignore suggestions about public keys, I haven't
found yet how to use those on cisco).



More information about the Python-list mailing list