Say, you want to put a text-based file on a router's flash memory. It could be a license file, a config file, or some scripts.
The 'regular' way is to use TFTP/FTP to transfer the file. But it could be a problem in some circumstances. For example:
1) You're accessing the router through a terminal server (console port). There's no network connectivity between your PC and the router.
2) Firewall/security policy prevents TFTP/FTP from happening.
It would be great if Cisco IOS has a 'notepad' (or 'vi') so we can create/edit the file from IOS CLI. But it has not.
Fortunately, Cisco IOS has tclsh. You may use tclsh create a file in flash memory and write some text to it.
Router#tclsh
Router(tcl)#puts [open "flash:script.txt" w+] "Some sample text"
Router(tcl)#tclquit
Router#dir flash:
Directory of flash:/
2 -rwx 2072 Jan 9 2014 10:24:23 -06:00 multiple-fs
3 -rwx 676 Feb 28 1993 18:01:35 -06:00 vlan.dat
4 -rwx 3570 Jan 9 2014 10:24:23 -06:00 private-config.text
5 -rwx 16 Jun 9 2014 09:34:35 -05:00 script.txt
6 drwx 192 Feb 28 1993 18:06:36 -06:00 c2960-lanbasek9-mz.122-55.SE7
562 -rwx 7340 Jan 9 2014 10:24:23 -06:00 config.text
32514048 bytes total (18987520 bytes free)
Router#more flash:script.txt
Some sample text
Router#
What if you want to create a file with multiple lines? Just escape the 'enter' with '\n'. For example:
Router(tcl)#puts [open "flash:script.txt" w+] "Line 1 \n Line 2 \n Line 3"
Hope this helps!
Ref: https://www.cisco.com/c/en/us/support/docs/ip/telnet/116214-technote-technology-00.html
Monday, June 9, 2014
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment