cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
6889
Views
0
Helpful
2
Replies

Redirecting TCL output to a file

rpeasah
Beginner
Beginner

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

 

1 Accepted Solution

Accepted Solutions

Charles Hill
Rising star
Rising star

"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.

View solution in original post

2 Replies 2

Charles Hill
Rising star
Rising star

"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.

miguelonio
Beginner
Beginner

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

 

 

-

 

 

 

 

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Recognize Your Peers