do while in cli?

Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
Is there anything that can help automate a configuration that is functionally the same as a do while loop?

Situation:

I am configuring authentication on sub interfaces on routers. I have about 12 in total. What I have been doing up to this point is using notepad and copy pasting my code over. What I would like to know is if there is something like a do while loop from the cli so I can only execute the command once. I know I can use the sdm and other tools to speed this up but I would rather do it from the cli.

I did google search and ask around and no one was able to give me an answer.

Comments

  • ColbyGColbyG Member Posts: 1,264
    Here's a TCL guide:

    Cisco IOS Scripting with Tcl - Cisco Systems

    I'm no good at scripting, but there should be something in there that would work. You could also use Perl.
  • Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    ColbyNA wrote: »
    Here's a TCL guide:

    Cisco IOS Scripting with Tcl - Cisco Systems

    I'm no good at scripting, but there should be something in there that would work. You could also use Perl.

    GREAT FIND!!!!!

    This is exactly what I needed to see.

    Pearl? You can run scripts of that nature on a cisco router? That might be easier to do once I get into scripting a little more. I was just being lazy because I have to do this 36 times. and I will need to do it again for my ipv6 configs.
  • kalebkspkalebksp Member Posts: 1,033 ■■■■■□□□□□
    If the interfaces are sequential you could use the interface range command, ie int range s0/0.1 - s0/0.5
  • Bl8ckr0uterBl8ckr0uter Inactive Imported Users Posts: 5,031 ■■■■■■■■□□
    kalebksp wrote: »
    If the interfaces are sequential you could use the interface range command, ie int range s0/0.1 - s0/0.5

    good find as well. Totally forgot about the range command.
  • ColbyGColbyG Member Posts: 1,264
    Perl is a scripting language. You wouldn't run the script on the router, you would run it on a machine. There are Cisco scripts out there if you search. I've got a couple Bash scripts that do basic stuff.
  • mikej412mikej412 Member Posts: 10,086 ■■■■■■■■■■
    Automation is fine for huge configuration tasks -- if you take the time to test in a lab environment first.

    The problems start to happen when you spend more time working on your scripts than it would take to just cut and paste. And you have to be careful that your shortcuts don't cause more problems and waste more time than any automation benefit would provide. Nothing says "your fired" more than screwing up 50+ device in one shot.

    That said.....

    The Cisco-centric Open Source Exchange Community
    :mike: Cisco Certifications -- Collect the Entire Set!
  • SepiraphSepiraph Member Posts: 179 ■■□□□□□□□□
    ColbyG wrote: »
    Perl is a scripting language. You wouldn't run the script on the router, you would run it on a machine. There are Cisco scripts out there if you search. I've got a couple Bash scripts that do basic stuff.

    Actually you can definitely use perl script to act on Cisco router, the idea is to execute the script on a host on which then you either use 1) telnet/ssh module or 2) setup snmp community string with write access, with router acting as the 'server'.
  • ColbyGColbyG Member Posts: 1,264
    Sepiraph wrote: »
    Actually you can definitely use perl script to act on Cisco router, the idea is to execute the script on a host on which then you either use 1) telnet/ssh module or 2) setup snmp community string with write access, with router acting as the 'server'.

    I'm pretty sure we're saying the same thing.
  • TurgonTurgon Banned Posts: 6,308 ■■■■■■■■■□
    mikej412 wrote: »
    Automation is fine for huge configuration tasks -- if you take the time to test in a lab environment first.

    The problems start to happen when you spend more time working on your scripts than it would take to just cut and paste. And you have to be careful that your shortcuts don't cause more problems and waste more time than any automation benefit would provide. Nothing says "your fired" more than screwing up 50+ device in one shot.

    That said.....

    The Cisco-centric Open Source Exchange Community

    Totally agree here. Do be careful folks.
  • TurgonTurgon Banned Posts: 6,308 ■■■■■■■■■□
    knwminus wrote: »
    good find as well. Totally forgot about the range command.

    The range command is priceless for all kinds of things.
  • TurgonTurgon Banned Posts: 6,308 ■■■■■■■■■□
    knwminus wrote: »
    Is there anything that can help automate a configuration that is functionally the same as a do while loop?

    Situation:

    I am configuring authentication on sub interfaces on routers. I have about 12 in total. What I have been doing up to this point is using notepad and copy pasting my code over. What I would like to know is if there is something like a do while loop from the cli so I can only execute the command once. I know I can use the sdm and other tools to speed this up but I would rather do it from the cli.

    I did google search and ask around and no one was able to give me an answer.

    The macro command might be another option. Have a look at that. EEM is another idea.
Sign In or Register to comment.