Fix the "do" command

The do command available in configuration modes of Cisco IOS is probably one of the best features ever implemented in IOS, but you tend to continue typing the do keyword even in the exec mode, resulting in syntax errors. The alias command doesn't help as you cannot specify an empty command line. However, there is a Tcl-based workaround.Store the following Tcl code in flash:do.tcl:

puts [exec $argv]
Configure alias exec do tclsh flash:do.tcl and you can execute the do command from exec mode.

The simple solution does not page the output, a lot more work would be needed to implement the proper paging functionality

5 comments:

  1. Hi Ivan,

    I'd try out your fix do command but I found error as shown below.

    ######################################

    Router#tclsh
    Router(tcl)#set x [open "flash:do.tcl" w+]
    Router(tcl)#set do {
    +>puts [exec $argv]
    +>}

    puts [exec $argv]

    Router(tcl)#puts $x $do
    Router(tcl)#close $x
    Router(tcl)#tclquit
    Router#show flash:

    System flash directory:
    File Length Name/status
    1 20 do.tcl [invalid checksum]
    [84 bytes used, 8388520 available, 8388604 total]
    8192K bytes of processor board System flash (Read/Write)


    Router(config)#alias do tclsh flash:do.tcl
    ^
    % Invalid input detected at '^' marker.

    Router(config)#

    ######################################

    Any suggestion?

    ReplyDelete
  2. Oh goch! maybe because I try it in dynamips. The bootflash seems to be unwrittable.

    Will try on real router and see result again. Anyway did alias do tclsh flash:do.tcl work? :D (I'm apologize if my question look impolite).

    ReplyDelete
  3. My error, the correct syntax is "alias exec do ...". I've fixed the post. The error has nothing to do with dynamips.

    Thanks for the correction!

    ReplyDelete
  4. amnuay, you can use nvram: instead of flash:, it's always available in dynamips.

    ReplyDelete
  5. Cool! to xavier. ;)
    it's now work fine.

    ReplyDelete

You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.

Ivan Pepelnjak, CCIE#1354, is the chief technology advisor for NIL Data Communications. He has been designing and implementing large-scale data communications networks as well as teaching and writing books about advanced technologies since 1990. See his full profile, contact him or follow @ioshints on Twitter.