06-16-2015 06:09 PM
Trying to use tcl to gather output from a number of show commands and redirect the output to a file.
1. Is there a way to suppress all the screen output. I just want to show the output and none of the tcl commands.
2. How do I send all the outputs (output1, output2 .....outputn) to a file on the flash for example.
tclsh
set output1 [ exec "show run int f0/1.101" ]
set output2 [ exec "show ip nhrp" ]
set output3 [ exec "show protocols | exclude down" ]
puts "\nBegin show run int f0/1.101"
puts $output1
puts "\nBegin show ip nhrp"
puts $output2
puts "\nBegin show protocols"
puts $output3
Solved! Go to Solution.
06-16-2015 08:10 PM
"How do I send all the outputs (output1, output2 .....outputn) to a file on the flash for example."
Try
show run int f0/1.101 | redirect filename.txt
This should send the output to your flash.
You can use the append command to append to the existing file.
http://www.cisco.com/c/en/us/td/docs/ios/fundamentals/configuration/guide/15_1s/cf_15_1s_book/feat_show_cmd_redrct.pdf
Hope this helps.
Please rate helpful posts.
Thanks.
06-16-2015 08:10 PM
"How do I send all the outputs (output1, output2 .....outputn) to a file on the flash for example."
Try
show run int f0/1.101 | redirect filename.txt
This should send the output to your flash.
You can use the append command to append to the existing file.
http://www.cisco.com/c/en/us/td/docs/ios/fundamentals/configuration/guide/15_1s/cf_15_1s_book/feat_show_cmd_redrct.pdf
Hope this helps.
Please rate helpful posts.
Thanks.
10-24-2017 01:18 PM
Hi guys,
Another option could be
set HOSTNAME [info hostname]
set FILE [open "flash:$HOSTNAME-command_output.txt" w]
set COMMAND_SHOW [list "show run int f0/1.101" "show ip nhrp" "show protocols | exclude down" "show run int f0/1.101" "show ip nhrp" "show protocols"]
foreach SHOW_COMMAND $COMMAND_SHOW {
puts $FILE "$HOSTNAME# $SHOW_COMMAND"
set COMMAND_OUTPUT [ exec $SHOW_COMMAND]
puts $FILE $COMMAND_OUTPUT
}
Hope this will be helpful
Regards
-
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