05-19-2016 01:49 PM - edited 03-08-2019 05:51 AM
Hi there
Every week I have to login to several servers and run #sh ver command which gives a long output. I just need the version number.
How can I schedule $sh ver to run every Sunday and extract (preferably just the version number) and dump it in a CSV file?
Help will be appreciated.
Thanks so much.
05-19-2016 04:15 PM
RANCID is very good at doing this kind of thing, and a lot more - and is free.
http://www.shrubbery.net/rancid/
It doesn't dump it to a CSV file, but monitors for changes and will tell you if it does change.
05-19-2016 04:53 PM
I assume you want to do that directly on routers or switches? If you want to do that through servers then rancid is a good tool.
On the routers or switches you can do commands with 2 pipes |.
For that you need to do sh ver | i Version and redirect output to a file.
I will suggest to solve that issue by using tcl scripts.
Here an example:
puts [open "flash:shver.tcl" w+] {
set file [open "flash:version.csv" "w+"]
set vers [exec "sh ver | i Version"]
set date [exec "sh clock"]
puts $file $date
puts $file $vers
close $file
}
kron occurrence VER at 0:16 sun recurring
policy-list VER
kron policy-list VER
cli enable
cli tclsh flash:shver.tcl
cli exit
You can even add a line in the policy to export that file on a ftp or tufts by using :
cli copy flash:/version.csv tftp://x.x.x.x/version.csv
Hope this answering your question
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide