cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1096
Views
0
Helpful
2
Replies

TCL script with timer for manipulating interfaces

Romain Fauvet
Level 1
Level 1

Hello

I find some TCL script for shutdown interfaces,

But now , i want to shutdown interfaces at an exact time.

For examples at 07:00 pm the F0/2 shutdown and the morning at 08:00 am the interface become up.

My problem is that I can not isolated from the time from the "show clock"

Do you have any information on that?

Is it possible tou execute this ?

Thank you

Romain F.

Ps: Sorry if my English is bad

2 Replies 2

Romain Fauvet
Level 1
Level 1

Hy everyone ,

If you are intersted , i find an answer to my question .

    set time [clock format [clock seconds] -format "%H%M%S"];

    while { $time <= 165530} {

            puts "$time";

            set time [clock format [clock seconds] -format "%H%M%S"];

        }

    set ifnum f0/15;

    puts ifnum

    puts "shut down interface $ifnum" ;

    set mode "interface $ifnum" ;

    set cmd "shutdown";

    ios_config $mode $cmd ;

    set time [clock format [clock seconds] -format "%H%M%S"];

    while { $time <= 165630} {

            puts "$time";

            set time [clock format [clock seconds] -format "%H%M%S"];

        }

    set ifnum f0/15;

    puts ifnum

    puts "shut down interface $ifnum" ;

    set mode "interface $ifnum" ;

    set cmd "no shutdown";

    ios_config $mode $cmd ;

It works like this :

At 16h55m30s , it shut down the interface

And at 16h56m30, it no shut down the interface

Have a nice day !

Hey

My script finaly work, there is the finaly version

set time [clock format [clock seconds] -format "%H%M%S"]

set date [clock format [clock seconds] -format "%D"]

while { $date <= "03/02/2014" } {

    while { $time <= "104230" } {

        set time [clock format [clock seconds] -format "%H%M%S"]

        set date [clock format [clock seconds] -format "%D"]

        }

    set ifnum f0/15

    puts "shut down interface $ifnum"

    set mode "interface $ifnum"

    set cmd "shutdown"

    ios_config $mode $cmd

    set date  [clock format [clock seconds] -format "%D"]

    set time [clock format [clock seconds] -format "%H%M%S"]

    while { $time <= "104330" } {   

        set time [clock format [clock seconds] -format "%H%M%S"]

        set date [clock format [clock seconds] -format "%D"]

        }

    set ifnum f0/15

    puts "no shut down interface $ifnum"

    set mode "interface $ifnum"

    set cmd "no shutdown"

    ios_config $mode $cmd

    set date [clock format [clock seconds] -format "%D"]

    set time [clock format [clock seconds] -format "%H%M%S"]

    set date_today [clock format [clock seconds] -format "%D"]

    while { $date <= $date_today } {   

        set time [clock format [clock seconds] -format "%H%M%S"]

        set date [clock format [clock seconds] -format "%D"]

        }

}

Bold characters can be change.

Have a nice day!

Romain F.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: