[TriLUG] expect question
Robert Dale
robdale at gmail.com
Mon Mar 9 15:42:06 EDT 2009
On Mon, Mar 9, 2009 at 2:36 PM, Greg Brown <gwbrown1 at gmail.com> wrote:
> So I've got a simple script. So far it logs into a router and goes to
> enable mode.
>
> I'd like to issue the command 'show run' then capture that output and write
> it to a log file. So far the expect script opens the log file but for the
> life of me I can't seem to capture the 'show run' output write that to the
> file.
>
> Can anyway share an example of how to do this?
#!/usr/bin/expect --
set log_file [open "foo.txt" "w"]
spawn w
expect eof {
puts $log_file $expect_out(buffer)
}
--
Robert Dale
More information about the TriLUG
mailing list