Hesky has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use expect_send, but it's hunging and I get:

ok 4 - expect_run Expect::Simple: couldn't find prompt after send at /home/hgreen/test/Test-Expect-0.29/lib/Test/Expect.pm line 72 # Looks like your test died just after 4.


I am trying to use a silly program:

#!/bin/ksh read -r var1?"Enter foo " echo $var1

In my test program I ahve included:

use Test::More tests => 5; use Test::Cmd; use Test::Harness; use Test::Expect; use Expect::Simple; use Expect;



And the invokation looks like:

expect_run( command => "/bbcm/devtools/tools/autoplink/tst", prompt => 'Enter foo ', quit => 'quit', ); expect('foo', 'foo', "expect"); expect_send('foo', "expect_send1");


Can someone tells me what am I doing wrong?

Edit g0n - added code tags

Edit g0n - retitled from "Test::Expect"

Replies are listed 'Best First'.
Re: Test::Expect : expect_send() dies
by davidrw (Prior) on Jul 07, 2005 at 01:29 UTC
    I believe (at least on my redhat/bash prompt i just tried) that read sends the prompt test (e.g. 'Enter Foo') to STDERR ... Does Test::Expect look at STDERR or just STDOUT? I couldn't tell from a quick look at the docs.

    To test this theory, i would try to change your silly program to be (note my use of bash -- i don't know redirecting syntax in ksh):
    #!/bin/bash read -r var1?"Enter foo " 2>&1 # is the read syntax here right for b +ash?? echo $var1
    Alternatively, the error_expect() method in Expect::Simple (what Test::Expect is build on) might be relevant, but not sure..

      The above has not resolve the problem expect_send still hangs.