[minicom-Bugs][311260] "expect" command cannot distinguish expected string "timeout" from command "timeout"

minicom-bugs at alioth.debian.org minicom-bugs at alioth.debian.org
Wed Dec 17 08:47:01 UTC 2008


Bugs item #311260, was opened at 2008-11-17 11:49
Status: Open
Priority: 3
Submitted By: jim lee (uukkhh-guest)
Assigned to: Nobody (None)
Summary:  "expect" command cannot distinguish expected string "timeout" from command "timeout"  
Category: None
Group: None
Resolution: None


Initial Comment:
I am sorry if it is a repeated report.

minicom "expect" command may consider another command "timeout", which is frequently used inside "expect", as an expected string! In other words, if the text being searched by "expect" command contains string "timeout", "expect" will try to execute the timeout value as a minicom statement and cause abnormal exit. 

For an example, if use "expect" to automatically login freebsd,

expect {
   "login:"
   timeout 300 goto exit_label
}
send username 

when booting freebsd, the following string appears:

" ...

bridge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500

    ether aa:aa:aa:aa:aa:aa id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp maxaddr 100 timeout 1200 root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0

... " 

The above "timeout" in "... maxaddr 100 timeout 1200 root..." caused minicom script to exit with a mesg of "300 is unknown statement."

I worked around this as follows but do not think it is a permanent solution. I modified src/script.c to replace
if (!strncmp(seq[f]->line, "timeout", 7)){
with
if (!strncmp(seq[f]->line, "timeout", 7)||!strncmp(seq[f]->line, "TiMeOuT", 7)) {
The string "TiMeOuT" is presumed not to appear in the text. 
Can we enforce that all searching strings must be enclosed with quotes?

----------------------------------------------------------------------

Comment By: Bill Bollenbacher (wcbwcb-guest)
Date: 2008-12-17 00:47

Message:
The existing code already allows the string 'timeout' to be a pattern, but only when it is double quoted ("timeout" [statement]).  It only allows it to be part of a timeout command when it is not.  So the code already correctly judges whether the string 'timeout' is a real command or a pattern, if you specify it correctly.

As stated in my last comment, the existing code should have deleted the timeout command from the list after it had correctly processed it, so that later it would not process it as a pattern.



----------------------------------------------------------------------

Comment By: jim lee (uukkhh-guest)
Date: 2008-12-16 18:34

Message:
The key point is to correctly judge whether a "timeout" inside a expect is a real command or a pattern being searched. Only with this part done, we may remove timout command from the list. 

  

----------------------------------------------------------------------

Comment By: Bill Bollenbacher (wcbwcb-guest)
Date: 2008-12-16 17:43

Message:
The correct fix for this would be to remove the timeout command from the seq list after it has been processed to extract the timeout value and action pair.  

Leaving it to be processed later as a pattern is obviously incorrect.



----------------------------------------------------------------------

You can respond by visiting: 
http://alioth.debian.org/tracker/?func=detail&atid=100031&aid=311260&group_id=30018



More information about the minicom-devel mailing list