We are currently evaluating the feasibilty of porting one of our tools
from unix to a native win32 environment using mingw. With the tool comes
its testsuite using the DejaGNU framework and thus Expect for Windows.
I managed to get a lot of things working but I'm still facing some
First question : has somebody used DejaGNU with expect for windows and
must we be prepared for specific issues with it ?
The second question is about a specific problem I'll explain/demonstrate
here. Take the following little C code :
printf("This is the beginning.\n");
system("echo Hello world!");
printf("This is the end.\n");
It prints a string, waits for a keypress, asks the command interpreter
to run something, waits for a second keypress and prints another string.
It seems there's a strang interaction between the 'system' call and
expect. To test, I use the following expect script :
set timeout 3
my_expect "This is the beginning.\n"
my_expect "Hello world!\n"
my_expect "This is the end.\n"
The script times out when waiting for 'Hello world!'. The output I get
This is the beginning.
Got 'This is the beginning.
Timeout triggered for 'Hello world!
write(spawn_id=]: broken pipe
(file "system.tcl" line 20)
So we timeout looking for the 'system' result, but the very bad thing is
that after this timeout, expect can't send anything to the tested
program anymore. So the question is two-fold :
1 - is there any way to 'expect' the result of the 'system' call ?
2 - Even if there's no way to get it, why does it break the rest of the
On a related note, I would be glad if someone could point me to a good
documentation regarding the console on windows, and particularly its
behavour when multiple process' (created via 'system' or
'CreateProcess') share a single console. I think I've seen cases where
expect wasn't able to read outputs of a child process, but I don't have
an example handy.