2

I would like to know if we can suppress certain lines from being displayed on the CLI. Example: I call following TCL script, that in itself calls some other scripts. What i Get on the screen is this:

switch#tclsh tftp://172.16.1.1/aliasmenu.tcl cpu
Loading aliasmenu.tcl from 172.16.222.89 (via Vlan10): !
[OK - 7140 bytes]
Calling second script
Loading aliascpu.tcl from 172.16.1.1 (via Vlan10): !
[OK - 198 bytes]
The argument given was cpu

What i'd like to see is just this:

switch#tclsh tftp://172.16.1.1/aliasmenu.tcl cpu
Calling second script
The argument given was cpu

So im looking for a way to suppres the Loading commands to the SSH VTY terminal output. I already tried with some discriminator commands:

logging discriminator HIDETCL msg-body drops Loading    
logging buffered discriminator HIDETCL
logging console discriminator HIDETCL
logging monitor discriminator HIDETCL

But they only work for Log messages. The Loading commands aren't log messages but direct outputs to the CLI. I tried the file prompt quiet command as well, as i thought maybe the copy command is behind the TCLsh command. But without any luck. Anyone else maybe had to deal with this type of request?

2 Answers 2

4

I would like to know if we can suppress certain lines from being displayed on the CLI.

Your most basic problem is that you're trying to drop non-logging messages with a logging command.

You can't make these messages disappear because they are not considered logging messages:

Loading aliasmenu.tcl from 172.16.222.89 (via Vlan10): !
[OK - 7140 bytes]

Consider looking at the output of show log and you'll discover that the lines above are never added to the logging buffer.

2
  • Well, thats what i wrote myself in the post already: But they only work for Log messages. The Loading commands aren't log messages but direct outputs to the CLI I just added these commands to prevent people from suggesting i should use logging discriminators. I guess what you wanna say with your post is: it cannot be done.
    – Mario Jost
    Commented May 20, 2019 at 8:41
  • If they are not supposed to work it’s pointless to put them in the question. You can’t turn those messages off and I still don’t understand why anybody would care. Even when automating the CLI output it’s easy to ignore them Commented May 20, 2019 at 11:45
1

I managed to do what i wanted with a TCL script, that is sitting on the local flash storage. If i give a command, it will try to download a TCL script with the same name from the TFTP Server and does not show the "loading" part in the CLI. This is the local script:

set proto "http://"
set host "172.16.20.5"
set path "/alias/"
set filename "help"
set extension ".tcl"
set remotepath "$proto$host$path$filename$extension"
set localpath "flash:$filename$extension"

if {$argc == "0"} {
        exec "copy $remotepath $localpath"
        source $localpath
        workload $argc $argv
        exec "delete $localpath"
} else {
        set filename [lindex $argv 0]
        set fakefilename "fake"
        set remotepath "$proto$host$path$filename$extension"
        set localpath "flash:$filename$extension"
        set remotefakepath "$proto$host$path$fakefilename$extension"
        set localfakepath "flash:$fakefilename$extension"
        set fakecopy [exec "copy $remotefakepath $localfakepath"]
        set copyresult [exec "copy $remotepath $localpath"]
        if {[lindex [exec "dir | include _$filename$extension"] 8] == "$filename$extension"} {
                source $localpath
                workload $argc $argv
                exec "delete /force $localpath"
        } else {
                puts "Command $argv not found. Use 'get help' for a list of available commands."
        }
}

On the Switch, there is following configuration:

alias exec get tclsh flash:alias.tcl

So if I enter

get cpu

the script tries to download http://172.16.20.5/alias/cpu.tcl and run it. So i can have a very short script deployed on all devices, but can still modify and deploy new scripts centrally.

1
  • One thing to note about this alias TCL script environment. You need to have file prompt quiet configured on the devices in order for them to run smooth. If you dont have the line, the scripts will freeze as they are waiting for user input for copy/delete operations in the flash.
    – Mario Jost
    Commented Dec 16, 2019 at 8:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.