如何解决使用“询问对话框”命令立即通过Bash命令传递文本
我想使用“询问对话框”命令立即传递问题。我正在尝试自动化启动终端并运行“询问对话框”的过程。每当我的bash脚本运行时,Alexa实例打开后就会暂停。
#!/bin/bash/
cd /Users/AlexaDirectory/
ask dialog
#this is where I need to ask Alexa a question automatically.
#I have tried running "ask dialog && (insert question)",but the script pauses once it reaches "ask dialog"
echo "end"
这是我在运行.sh时通常看到的内容
MacBook-Pro Desktop % bash Test.command
Defaulting locale to the first value from the skill manifest: en-US
======================================= Welcome to ASK Dialog =======================================
=========== In interactive mode,type your utterance text onto the console and hit enter ============
===================== Alexa will then evaluate your input and give a response! ======================
=== Use ".record <fileName>" or ".record <fileName> --append-quit" to save list of utterances to a file. ===
=============== You can exit the interactive mode by entering ".quit" or "ctrl + c". ================
User >
如果无法立即通过问题,是否可以向终端发送击键?
解决方法
答案是在查尔斯·达菲(Charles Duffy)的帮助下。
在调用docker run -d -p 9999:8080 my-go-image
并且修复程序正在发送ask dialog
时,该过程冻结。这也立即终止了Alexa实例。
您可以尝试使用the expect
command。我一直在努力解决类似的问题。在非交互模式下运行ask init
。最后,我像这样解决了它。
echo '#!/usr/bin/expect
spawn ask init
expect "? Skill Id (leave empty to create one):"
send "my-skill\r"
expect "? Skill package path:"
send "./path/to/skill-package\r"
expect "? Lambda code path for default region (leave empty to not deploy Lambda):"
send "./path/to/lampda-package\r"
' > ask_init.sh
chmod u+x ask_init.sh
./ask_init.sh
仅供参考,我还尝试使用|
和echo
的组合来传递答案,就像这样:
echo 'quantum-skill
./path/to/skill-package
./path/to/lampda-package
' | ask init
和printf
,如下所示:
printf 'quantum-skill\n./path/to/skill-package\n./path/to/lambda-package\n' | ask init
后者都不起作用。因此,我建议改用expect
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。