Expect script and show command capture problem.

Unanswered Question
Jun 28th, 2010
User Badges:

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,

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (0 ratings)
Loading.
John Blakley Tue, 06/29/2010 - 09:35
User Badges:
  • Purple, 4500 points or more

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

t8t6p2m054 Tue, 06/29/2010 - 16:40
User Badges:

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.

masonkevin Fri, 07/02/2010 - 07:00
User Badges:

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

yjdabear Fri, 07/02/2010 - 08:10
User Badges:
  • Gold, 750 points or more

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

Actions

This Discussion

Related Content