cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1353
Views
8
Helpful
2
Replies

"tail -f" equivalent on IOS/CatOS CLI?

yjdabear
VIP Alumni
VIP Alumni

Want to double check on whether "show commands | includ search-string" behaves the similarly as "tail -f filename | grep search-string" on UNIX CLI? Does it update *live* on IOS/CatOS CLI, even with "set length 0"? It doesn't seem so. Is there any way to achieve something similar to "tail -f"?

2 Replies 2

akemp
Level 5
Level 5

Not in traditional IOS. You would have to use TCL and call the command every X minutes or seconds. Thats due to the "run to completion" functionailty

IOS with software modularity, since it has a QNX kernel (like IOS-XR), has more potential as it has protected memory spaces..

Tail -f (follow) is a process that doesnt terminate if the object is not a pipe, but rather will enter in an endless loop sleeping for a second then will attempt to read and copy further records from the input file.

Term mon, deb config is the closest you'll get with traditional IOS

Joe Clarke
Cisco Employee
Cisco Employee

Here is a simple tail (without the -f) written in IOS Tcl by one of our Tcl developers (not me).

proc tail { show_cmd { n 10 } } {

set eol "\n"

if {[catch {set show_out [exec $show_cmd]}]} {

puts $fd

return

} else {

set data [split $show_out $eol]

}

for {set i [expr {[llength $data]-($n+1)}]} \

{$i<=[expr {[llength $data]-2}]} {incr i} {

puts [lindex $data $i]

}

}

You could adapt it for tail -f by calling the desired command periodically, checking the size of the output, and printing out the new data after the last size checkpoint. The liveliness of the updates would depend on how often you run the command. The more often you run the command, the more CPU impact you'll have.

This script requires IOS 12.3(2)T, but probably could be adapted to run on CatOS 8.x which has its own Tcl interpreter (though a much older version with some changes).