cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
9469
Views
0
Helpful
4
Replies

Expect script and show command capture problem.

t8t6p2m054
Level 1
Level 1

Hello everyone.

I want to capture the output of 'show interface status' to text files for our +600 switches.  Unfortunately, we have many old 2924's and other models running code prior to 12.0(21) that cannot support 'show command | redirect tftp....'  My hope was to use this command set and run it in an Expect script to capture this information on a daily basis.  Running the 'show interface status' in an Expect script is pretty easy, but I cannot see how to capture the show command output to a file for transfer to a server.  Has anyone else faced this problem and found a solution?

Thanks,

4 Replies 4

John Blakley
VIP Alumni
VIP Alumni

I had the same problem. You may want to look into a perl script to output the information into a text file, and then use the same perl script to then transfer the text file to whereever you need it.

HTH,

John

HTH, John *** Please rate all useful posts ***

Thanks John,

I may end up doing that but I've found an Expect script to open a text file and I'm seeing what I can do with it.  Let's see how long it will take to run and open +600 files.

If you can, could you share the script location?  It sounds like a handy one to have in the tool box.

yjdabear
VIP Alumni
VIP Alumni

To write the "show" commands output to a text file in Expect/Tcl:

set filename "/path/to/output.file"

exp_send "show running\r"

set var $expect_out(buffer);
set fid [open ${filname} w+]
put $fid $var
close ${fid}

Large "show" output can often exceed the default size of $expect_out(buffer) however. This can be tuned accordingly:

http://wiki.tcl.tk/9407

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: