Reputation: 2052
I'm trying to use expect
to talk to a bash
script, but I'm missing something. My script is:
#!/bin/bash
echo -n "foo? "
read
echo $REPLY
and my expect
script is:
#!/usr/bin/expect
spawn ./script.sh
expect "foo? "
send "bar\r\n"
But I never see bar
when I run the expect
script. What am I missing here?
Upvotes: 1
Views: 2102
Reputation: 27581
I don't familiar well with expect
syntax, but you worth try autoexpect
:
autoexpect ./script.sh
It will run script.sh
and after you'll finish running it an expect script script.exp
will be created in current directory.
After than you can edit it if you need to tune something in it.
Upvotes: 1
Reputation: 2052
Dumb me, I needed to add interact
to my expect
script so that it can finish "interacting" with the script:
#!/usr/bin/expect
spawn ./script.sh
expect "foo? "
send "bar\r\n"
interact
I found the answer here two minutes after asking this question.
Upvotes: 2