Batch Cisco Configuration Script

Discussion in 'Cisco' started by Paul Thomas, Jun 26, 2007.

  1. Paul  Thomas

    Paul Thomas Guest

    I've seen a script a few years ago that would automate the
    configuration of many routers but now I cannot find it unfortunately.
    The way the script would work is as follows. I can't use Kiwi Cat
    Tools because I have more than 5 devices and no budget for this
    project and also I would really like to use this from unix.

    The user would create the items to be placed into the config exactly
    as you would type them if you were telnet/ssh in (including any no
    commands if needed). You would place these commands into a plain text
    file with the filename being the device hostname/ip. When you ran the
    script you would pass it a directory and the script would telnet to
    each device (obtained from the filename) then send that file to the
    open telnet session.

    tFTP isn't an option for me as this is a lab environment with no
    access other than a termserv. I cannot put the configs on a file
    server / router in the lab as there isn't always connectivity to all
    devices. The only constant access to the devices is telnetting to a
    termserv. Security isn't a concern either.

    Google isn't giving me any love on this one and I'm trying to avoid
    recreating the will using Net::Telnet[::Cisco] if I don't have to.
    Paul Thomas, Jun 26, 2007
    #1
    1. Advertising

  2. Paul Thomas a écrit :
    > I've seen a script a few years ago that would automate the
    > configuration of many routers but now I cannot find it unfortunately.
    > The way the script would work is as follows. I can't use Kiwi Cat
    > Tools because I have more than 5 devices and no budget for this
    > project and also I would really like to use this from unix.
    >
    > The user would create the items to be placed into the config exactly
    > as you would type them if you were telnet/ssh in (including any no
    > commands if needed). You would place these commands into a plain text
    > file with the filename being the device hostname/ip. When you ran the
    > script you would pass it a directory and the script would telnet to
    > each device (obtained from the filename) then send that file to the
    > open telnet session.
    >
    > tFTP isn't an option for me as this is a lab environment with no
    > access other than a termserv. I cannot put the configs on a file
    > server / router in the lab as there isn't always connectivity to all
    > devices. The only constant access to the devices is telnetting to a
    > termserv. Security isn't a concern either.
    >
    > Google isn't giving me any love on this one and I'm trying to avoid
    > recreating the will using Net::Telnet[::Cisco] if I don't have to.


    IIRC, it could be "CiscoT", that you can find here:

    ftp://ftp.ripe.net/pride/tools/contrib.tar.gz

    Hope this helps.
    Christophe Fillot, Jun 26, 2007
    #2
    1. Advertising

  3. Paul  Thomas

    Paul Thomas Guest

    On Jun 26, 12:02 pm, Christophe Fillot <> wrote:
    > Paul Thomas a écrit :
    >
    >
    >
    > > I've seen a script a few years ago that would automate the
    > > configuration of many routers but now I cannot find it unfortunately.
    > > The way the script would work is as follows. I can't use Kiwi Cat
    > > Tools because I have more than 5 devices and no budget for this
    > > project and also I would really like to use this from unix.

    >
    > > The user would create the items to be placed into the config exactly
    > > as you would type them if you were telnet/ssh in (including any no
    > > commands if needed). You would place these commands into a plain text
    > > file with the filename being the device hostname/ip. When you ran the
    > > script you would pass it a directory and the script would telnet to
    > > each device (obtained from the filename) then send that file to the
    > > open telnet session.

    >
    > > tFTP isn't an option for me as this is a lab environment with no
    > > access other than a termserv. I cannot put the configs on a file
    > > server / router in the lab as there isn't always connectivity to all
    > > devices. The only constant access to the devices is telnetting to a
    > > termserv. Security isn't a concern either.

    >
    > > Google isn't giving me any love on this one and I'm trying to avoid
    > > recreating the will using Net::Telnet[::Cisco] if I don't have to.

    >
    > IIRC, it could be "CiscoT", that you can find here:
    >
    > ftp://ftp.ripe.net/pride/tools/contrib.tar.gz
    >
    > Hope this helps.


    Thanks for the prompt reply but that's not what I was looking for.
    Here is an example.

    The following files are in /tmp/cisco/changes
    cat host1
    conf t
    no ip access-list 10
    ip access-list 10 permit ip any any
    end
    wr me

    ##
    cat host2
    conf t
    no ip access-list 10
    ip access-list 10 permit ip any any
    end
    wr me

    I would then type 'pushchanges /tmp/cisco/changes' and it would log
    into routers, enter enable mode, then cat the text to the telnet
    session. I made up the name pushchanges and I have no idea what
    language that script was written in.

    I expect I'll be writing some perl to do this but just trying not to
    re-invent the wheel....especially since I'm not a fast (or good)
    programmer.
    Paul Thomas, Jun 26, 2007
    #3
  4. Paul  Thomas

    Sam Wilson Guest

    In article <>,
    Paul Thomas <> wrote:

    > ...
    > I would then type 'pushchanges /tmp/cisco/changes' and it would log
    > into routers, enter enable mode, then cat the text to the telnet
    > session. I made up the name pushchanges and I have no idea what
    > language that script was written in.
    >
    > I expect I'll be writing some perl to do this but just trying not to
    > re-invent the wheel....especially since I'm not a fast (or good)
    > programmer.


    We use an expect script to do this kind of thing, but I'd be slightly
    embarrassed to pass it on. (And I didn't write it, though that's not a
    boast that I'd have done any better.)

    Sam
    Sam Wilson, Jun 27, 2007
    #4
  5. On 27 jun, 05:41, Sam Wilson <> wrote:
    > In article <>,
    > Paul Thomas <> wrote:
    >
    > > ...
    > > I would then type 'pushchanges /tmp/cisco/changes' and it would log
    > > into routers, enter enable mode, then cat the text to the telnet
    > > session. I made up the name pushchanges and I have no idea what
    > > language that script was written in.

    >
    > > I expect I'll be writing some perl to do this but just trying not to
    > > re-invent the wheel....especially since I'm not a fast (or good)
    > > programmer.

    >
    > We use an expect script to do this kind of thing, but I'd be slightly
    > embarrassed to pass it on. (And I didn't write it, though that's not a
    > boast that I'd have done any better.)
    >
    > Sam


    Paul,

    Here follow a simple example of a expect script. It only logs into the
    router and then give the prompt back to the user (that is what the
    interact command does). You pass the IP of target as parameter
    (scriptname.exp 10.10.10.10).

    But you can improve it to send the strings you need... 'send' command
    simulates a user typing and 'expect' waits for that string... well, I
    suggest you reading the Expect/Tcl docs so you can pass parameters to
    the script.

    the script:
    --------------------
    #!/usr/local/bin/expect

    spawn telnet $argv

    expect "Username:"
    send "johndoe\r"

    expect "Password:"
    send "secret\r"

    expect "\>"
    send "en\r"

    expect "Password:"
    send "zekret\r"

    interact
    --------------------

    Regards,
    Adriano
    Adriano Prado, Jun 27, 2007
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. test
    Replies:
    3
    Views:
    17,074
  2. vincecup17

    batch script for copying folder only

    vincecup17, Sep 9, 2009, in forum: Computer Support
    Replies:
    1
    Views:
    456
    vincecup17
    Sep 10, 2009
  3. Replies:
    3
    Views:
    3,899
    Wolfgang Weisselberg
    Dec 13, 2009
  4. zigzagdna

    Running dos command batch script

    zigzagdna, Jan 9, 2010, in forum: Windows 64bit
    Replies:
    0
    Views:
    505
    zigzagdna
    Jan 9, 2010
  5. zigzagdna

    Running dos command batch script

    zigzagdna, Jan 9, 2010, in forum: Windows 64bit
    Replies:
    0
    Views:
    352
    zigzagdna
    Jan 9, 2010
Loading...

Share This Page