Reputation: 153311
I have a program that ask for input. For example:
$ program arg1 arg2
Enter the value of arg3: foo
Enter the value of arg4: spam
$
How can I automatize the running? I suspect the expect
provide the functionality for that but the following does not work for me:
#!/usr/bin/expect
set timeout 20
spawn "./program arg1 arg2"
expect "Enter the value of arg3:" { send "foo\r" }
expect "Enter the value of arg4:" { send "spam\r" }
interact
Does anyone have ideas? Thanks.
Upvotes: 0
Views: 57
Reputation: 246774
Try doing it the simplest way possible (without expect): Does this work?
program arg1 arg2 <<END
foo
spam
END
(or printf "%s\n" foo spam | program arg1 arg2
)
Upvotes: 1