Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 348671 - dev-tcltk/expect-5.44.1.15 does not honor its "timeout" or "eof" expectations
Summary: dev-tcltk/expect-5.44.1.15 does not honor its "timeout" or "eof" expectations
Status: RESOLVED TEST-REQUEST
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: TCL/TK Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-14 03:44 UTC by Kevin O'Gorman
Modified: 2016-05-06 10:52 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
A bash script that counts to three (count.sh,49 bytes, text/plain)
2010-12-14 03:46 UTC, Kevin O'Gorman
Details
An expect script that should wait for a "four" (script.exp,234 bytes, text/plain)
2010-12-14 03:47 UTC, Kevin O'Gorman
Details
Script that recognizes eof and timeout as documented (script1.exp,237 bytes, text/plain)
2010-12-18 17:20 UTC, Kevin O'Gorman
Details
Script that fails to recognize eof or timeout, but I don't know why. (script2.exp,233 bytes, text/plain)
2010-12-18 17:21 UTC, Kevin O'Gorman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin O'Gorman 2010-12-14 03:44:19 UTC
I have been unable to get Expect to recognize and respond appropriately to early end-of-file or to timeout.  This occurs in console terminals as well as various X windows.  I have short sample code.

Reproducible: Always

Steps to Reproduce:
1.Put script.exp and count.sh in the current directory.
2.Make count.sh executable; set the timeout number to -1 or some positive integer (seconds).
3.enter "expect script.exp"

Actual Results:  
It shows output from count.sh then "Normal end"

Expected Results:  
Since the script is expecting the word "four", it should either time out (if the timeout is not set to -1), or an early EOF from the program.  It does neither.

This is also happening in my Ubuntu version, so I think this may be widespread.
Comment 1 Kevin O'Gorman 2010-12-14 03:46:23 UTC
Created attachment 257072 [details]
A bash script that counts to three
Comment 2 Kevin O'Gorman 2010-12-14 03:47:16 UTC
Created attachment 257073 [details]
An expect script that should wait for a "four"
Comment 3 Kevin O'Gorman 2010-12-17 02:56:43 UTC
It turns out that a minor change to the text of script.exp makes this work again. I can find no documentation in the Expect manual of why this might be so, but adding a newline and whitespace to change

expect { -exact "four\r" { exit 1; }
     timeout { send_user "\ntimeout\n"; exit 2; }
     eof { send_user "\nEarly end\n"; exit 3; }
}

to

expect { 
     -exact "four\r" { exit 1; }
     timeout { send_user "\ntimeout\n"; exit 2; }
     eof { send_user "\nEarly end\n"; exit 3; }
}

makes the timeout and eof capabilities work as "expected".  I know of no rule that explains this, but I have a workaround.
Comment 4 SpanKY gentoo-dev 2010-12-17 23:20:58 UTC
seems to work for me:
$ expect -v
expect version 5.44.1.15
$ ./script.exp 
spawn ./count.sh
one
two
three
Normal end
Comment 5 Kevin O'Gorman 2010-12-18 15:18:12 UTC
(In reply to comment #4)
> seems to work for me:
> $ expect -v
> expect version 5.44.1.15
> $ ./script.exp 
> spawn ./count.sh
> one
> two
> three
> Normal end

That's really odd.  I only found the cause because a friend using a different distro hand-entered the expect code, and didn't find the problem at first.  He
found it when he examined closely and realized he'd rearranged the whitespace.
I then found that the same rearrangement made the problem go away on my system.

I'm seeing the same thing in Ubuntu Lucid and Fedora Core 11, so I've assumed this is an upstream generic problem.

A long shot: What's your machine architecture?  I'm running x86 32-bit all the way.
Comment 6 Kevin O'Gorman 2010-12-18 17:19:37 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > seems to work for me:
> > $ expect -v
> > expect version 5.44.1.15
> > $ ./script.exp 
> > spawn ./count.sh
> > one
> > two
> > three
> > Normal end
> 
> That's really odd.  I only found the cause because a friend using a different
> distro hand-entered the expect code, and didn't find the problem at first.  He
> found it when he examined closely and realized he'd rearranged the whitespace.
> I then found that the same rearrangement made the problem go away on my system.
> 
> I'm seeing the same thing in Ubuntu Lucid and Fedora Core 11, so I've assumed
> this is an upstream generic problem.
> 
> A long shot: What's your machine architecture?  I'm running x86 32-bit all the
> way.
> 

Oops, correction: That was Fedora Core 9 I used to verify the issue.

And I've just done the same on CentOS 5.2 (Final)

I'm attaching a script1.exp and script2.exp which are the two variants with unexplained differences in results.
Comment 7 Kevin O'Gorman 2010-12-18 17:20:42 UTC
Created attachment 257505 [details]
Script that recognizes eof and timeout as documented
Comment 8 Kevin O'Gorman 2010-12-18 17:21:26 UTC
Created attachment 257506 [details]
Script that fails to recognize eof or timeout, but I don't know why.
Comment 9 SpanKY gentoo-dev 2010-12-18 19:55:49 UTC
you could try expect-5.45, but if that fails too and on other distros, then best place probably is sf.net/projects/expect ...