How to get ouput from expect
- by Mallikarjunarao
i wrote a script for spawing the bc command
package require Expect
proc bc {eq} {
spawn e:/GnuWin32/bc/bin/bc
send "$eq\r"
expect -re "(.*)\r"
return "$expect_out(0,string)"
}
set foo "9487294387234/sqrt(394872394879847293847)"
puts "the valule [bc $foo]"
how to get the output from this. When i am running this one i get ouput like this
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
9487294387234/sqrt(394872394879847293847)
477
can't read "expect_out(0,string)": no such element in array
while executing
"return "The values is $expect_out(0,string)""
(procedure "bc" line 6)
invoked from within
"bc $foo"
invoked from within
"puts "the valule [bc $foo]""
(file "bc.tcl" line 21)
how to resolve this one.