Edit files using TCL

From Internetworkpro

Jump to: navigation, search
This page or section provides device configuration instructions
Please note that the information on this page has not been checked for accuracy and is not intended as a replacement to documentation. Please ensure you understand your desired objectives before attempting to apply any examples listed.
This page or section has been marked as requiring improvement.
Please review this page or section and make any stylistic or grammar changes necessary to improve the article. For assistance, please check the Page Guidelines

I tested this using 12.4

First goto tclsh:

Router#tclsh 

Now open the file. The w+ means that you will override the file.

Router(tcl)#set x [open "flash:a.txt" w+] 
file0

Now run the first command "set lst {", then paste the content of the file and finish with "}"

Router(tcl)#set lst {
+>no access-list 100
+>access-list 100 per ip any host 1.1.1.1
+>}

no access-list 100
access-list 100 per ip any host 1.1.1.1

Now write the file and close it

Router(tcl)#puts $x $lst

Router(tcl)#close $x

Quit TCL

Router(tcl)#tclquit 

Enjoy...

Personal tools