Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Expectk on SuSe 10.x

45 views
Skip to first unread message

Why Tea

unread,
Oct 18, 2007, 10:00:52 PM10/18/07
to
I have just tried some Expectk code (developed on Solaris) on SuSe and
found that Expectk was no longer compiled separately. According to a
relevant site:
- Don't build the expectk binary anymore to remove the buildtime
dependency on Tk and X. Scripts that needed to run in expectk
before can be fixed by running them in expect and adding a line
that says "package require Tk" before the first tk command
is executed.

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

unread,
Oct 18, 2007, 10:26:00 PM10/18/07
to
I probably should add this: if I ran expect followed by "package
require Tk", the Wish window came up OK. When I ran the script file
with "package require Tk", it just dropped back to the shell prompt
with no error messages.

/Why Tea

Uwe Klein

unread,
Oct 19, 2007, 4:16:10 AM10/19/07
to
Why Tea wrote:

>>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

Why Tea

unread,
Oct 19, 2007, 7:38:40 AM10/19/07
to
I was running on SuSe 10.3.

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.

Uwe Klein

unread,
Oct 19, 2007, 10:02:36 AM10/19/07
to
Why Tea wrote:
> I was running on SuSe 10.3.
>
> 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

Why Tea

unread,
Oct 21, 2007, 7:51:48 PM10/21/07
to
On Oct 20, 12:02 am, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:


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.

Ivan Young

unread,
Oct 22, 2007, 4:40:03 AM10/22/07
to
Do you have a vwait at the end of your script ?


#!/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.


Uwe Klein

unread,
Oct 22, 2007, 5:25:51 AM10/22/07
to
Ivan Young wrote:

>
> 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


Why Tea

unread,
Oct 22, 2007, 7:56:05 PM10/22/07
to
On Oct 19, 6:16 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:

I tried your code and it worked fine.

Why Tea

unread,
Oct 22, 2007, 7:58:44 PM10/22/07
to
On Oct 22, 7:25 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:

I tried it and Wish ran OK (i.e. I got the window, menu, ...) except
when it came to the Expect specific code.

Uwe Klein

unread,
Oct 23, 2007, 4:50:27 AM10/23/07
to
Why Tea wrote:

> 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

Why Tea

unread,
Oct 23, 2007, 8:19:37 PM10/23/07
to
On Oct 23, 6:50 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>
wrote:

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".

Uwe Klein

unread,
Oct 24, 2007, 3:56:23 AM10/24/07
to
UUps, my error:

% package require expect


can't find package expect

% package require Expect
5.40.0
%

use
package require Expect

uwe

Why Tea

unread,
Oct 24, 2007, 7:56:15 PM10/24/07
to
On Oct 24, 5:56 pm, Uwe Klein <uwe_klein_habertw...@t-online.de>

Thanks Uwe, it's working as expected now. Should have noticed the
upper case 'E'...

0 new messages