【发布时间】:2014-09-22 13:43:43
【问题描述】:
我需要一些帮助。
操作系统:Mac osSX 10.9.4
我正在运行一个 bash 脚本,如下所示: sh create-emulator.sh AVD_16 14 /usr/local/ks-test-automation/avd-lib/x86 QVGA
代码:
create_emulator() {
android create avd -n $Emulator -t $Target -p $Location --abi $Processor --skin $Skin --force
expect "Android 4.4.2 is a basic Android platform."
expect "Do you wish to create a custom hardware profile [no]"
send "no\n"
}
main_method() {
create_emulator
}
Emulator="$1"
Target="$2"
Location="$3"
Processor="$4"
Skin="$5"
main_method
使用 ctrl+c 退出脚本后的输出:
Couldn't read file "Android 4.4.2 is a basic Android platform.": no such file or directory
couldn't read file "Do you wish to create a custom hardware profile [no]": no such file or directory
/usr/local/ks-test-automation/shell-script-lib/create-emulator.sh: line 14: send: command not found
提前致谢
【问题讨论】:
-
我很确定您的期望语法是错误的。检查
expectman page -
我不认为
expect做你认为它做的事情。 -
@njzk2 我认为
expects 的目的正是 OP 所追求的,但他没有正确使用它。 -
我想你至少需要使用
spawn来启动android命令。此外,您缺少作为脚本第一行的“shebang”:#!/usr/bin/expect(如果这是安装期望的位置)。鉴于您看到的错误消息,我认为您的脚本实际上被解释为普通的 shell 脚本而不是期望。 -
^^ @zerodiff:不,你可以在 bash 下运行脚本。您可以为此运行
expect -c。
标签: android macos bash shell expect