Hello,
So my first problem is I'm trying to create a tcl script which will print out the file name of the image currently running. I've got this so far.
set output [ split [ exec "show version" ] "\n" ]
foreach line $output {
if { [ llength $line ] > 0 } {
if { [ regexp "^.+?System image file is \"(.+?)\"" [ lindex $line 0 ] ] } {
puts $line
}
}
}
Now what bugs me to hell is this:
If I save the show version in a file and run egrep with the regex "^.+?System image file is \"(.+?)\"" I get the reply:
System image file is "flash:c181x-advipservicesk9-mz.124-15.T3.bin"
However when I run the tcl script in the router I don't get any hit.... and this is very confusing. The only time I've actually gotten a hit was when I just wrote the regex ^System, but then I get 3 lines and in the end all I actually want to return is the image file name and nothing else. I had planned to use something like "c18(.+?)[bin]" to do that but the TCL script complained as hell on that regex. I know using the c18 is technically a little cheating but it doesn't matter since the script I'm working on will always be running on one type of router (1800 series).
Anyone got a clue to what is going on here? Is cisco regex engine limited? And if this should be on another forum I'm not sure, but I think this was the best place.