But it didn't work for me after I added "package require Tk" and
changed the first line to #!/usr/bin/expect.
Has anyone encountered the same problem?
/Why Tea
/Why Tea
>>Has anyone encountered the same problem?
>>
>>/Why Tea
>
>
Try the following script,
I have tested it on SuSE 9.1 and 10.2 boxes
uwe
>
#!/usr/bin/expect
package require Tk
puts "started,Tk found"
button .b -text Date -command getdate
entry .e -textvariable ::lvar
pack .e .b
proc getdate {} {
spawn date
expect -re .*\n {
puts stderr Date:$expect_out(0,string)
set ::lvar $expect_out(0,string)
exp_continue
} eof {
puts stderr EOF:Done
}
wait
puts stderr Exit
}
puts "waiting, press the button"
vwait forever
#end
It worked if I ran the my script the following way:
- ran expect
- > package require Tk
- > source mine.exp
However, if I just run mine.exp (with "package require Tk" inside), it
drops back to the Linux shell prompt right away.
any errormessage?
could you post the beginning of your script?
uwe
No error messages. I have "package require Tk" right after the
"#!....".
I think the script must be OK as it runs fine from expect command line
as I stated in the previous message.
#!/bin/env expect
package require Tk
button .b -text "hello" -command "exit"
pack .b
#vwait forever
# Uncomment above to not exit !
Unlike "package require Tk" from tclsh the event loop is not entered by default.
Ivan.
>
> Unlike "package require Tk" from tclsh the event loop is not entered by
> default.
>
> Ivan.
>
The best think to do may be to
run these scripts via wish
and do a [require package expect]
i.e change
#!/usr/bin/expectk
to
#!/usr/bin/wish
package require expect
which should reproduce the original behaviour.
uwe
I tried your code and it worked fine.
I tried it and Wish ran OK (i.e. I got the window, menu, ...) except
when it came to the Expect specific code.
> I tried it and Wish ran OK (i.e. I got the window, menu, ...) except
> when it came to the Expect specific code.
>
is it mum or did you get a specific errormessage?
did you insert the following line at the top?
package require expect
uwe
I did. Sorry I should have mentioned the error message with expect as
a package. Since expect is not a package, it's reported as "can't find
package expect".
% package require expect
can't find package expect
% package require Expect
5.40.0
%
use
package require Expect
uwe
Thanks Uwe, it's working as expected now. Should have noticed the
upper case 'E'...