我有一个要求输入的程序。例如:
$ program arg1 arg2
Enter the value of arg3: foo
Enter the value of arg4: spam
$
如何使运行自动化?我怀疑expect
为此提供了功能,但以下内容对我不起作用:
#!/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
有人有想法吗?谢谢。