使用 expect 模拟用户输入
Using expect to emulate user input
我试图在命令行上的脚本安装期间在 [y/N]
提示中回答 y
(-y
不是一个选项)。
到目前为止我有以下内容:
#!/bin/bash
expect << EOF
dasht-docsets-install expressjs
expect "[y/N]"
send "y"
EOF
但这给出了以下输出:
invalid command name "dasht-docsets-install"
while executing
"dasht-docsets-install expressjs"
我有多个文档集要安装,一次只能安装一个,即我不能去 dasht-docsets-install expressjs vuejs
等等...所以理想情况下我想创建一个 bash 函数可以像这样递给 docset
:
doc_install expressjs
这将负责处理输入。
如有任何帮助,我们将不胜感激。
使用这个:
dasht-docsets-install -f expressjs
# `-f`, `--force`
# Forces the operation by overriding the interactive confirmation prompt.
来源:github repo.
我试图在命令行上的脚本安装期间在 [y/N]
提示中回答 y
(-y
不是一个选项)。
到目前为止我有以下内容:
#!/bin/bash
expect << EOF
dasht-docsets-install expressjs
expect "[y/N]"
send "y"
EOF
但这给出了以下输出:
invalid command name "dasht-docsets-install"
while executing
"dasht-docsets-install expressjs"
我有多个文档集要安装,一次只能安装一个,即我不能去 dasht-docsets-install expressjs vuejs
等等...所以理想情况下我想创建一个 bash 函数可以像这样递给 docset
:
doc_install expressjs
这将负责处理输入。
如有任何帮助,我们将不胜感激。
使用这个:
dasht-docsets-install -f expressjs
# `-f`, `--force`
# Forces the operation by overriding the interactive confirmation prompt.
来源:github repo.