I've tried:
set spawn_id [ $dut get_sshspid ]
send "show server statistics\r"
expect "*"
puts "This is the output of the command: "
puts $expect_out(buffer)
The above snippet doesnt work and reports the error
Failed to execute due to error : can't read "expect_out(buffer)": no such
variable
I am fairly new to expect/tcl and am not sure if $expect_out(buffer) would
be defined in a tcl script..Can someone pleae show me how I can save
the output of a command into a variable?
Thanks,
--ravi
Ravi Parimi wrote:
expect * doesn;t do what you think it does, it says zero
or more chars - so you get zero - it matches so it doesn't
even look for more. since you never look for anything, anywhere
expect_out isn;t evr being filled in.
you want to look for specific things
generally you want
expect $prompt ;# wait for a prompt
send $command\r ;# send command
expect $command\n ;# see command echo back
expect -re "(.*)$prompt ;# see next prompt
now expect_out(buffer) should be everything (including prompt)
and excpect_out(string,1) should be results of your command
if you command returns large amounts of data you might have
to expand that by grabbing chunks at a time until you see
the prompt.
Bruce
Cameron Laird <cla...@phaseit.net>
Business: http://www.Phaseit.net
Thank you very much for your reply. I tried the exact sequence of commands
you mentioned and was able to look at the server output in
expect_out(buffer). Thanks again!
--ravi