1

我想使用“询问对话”命令立即传递问题。我正在尝试自动化启动终端和运行“询问对话框”的过程。每当我的 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  > 

如果无法立即传递问题,是否可以向终端发送击键?

4

2 回答 2

0

在Charles Duffy 的帮助下,使用herestring 就是答案。

调用时进程冻结ask dialog,并且修复正在发送ask dialog <<< "question for alexa placed here". 这也会立即结束 Alexa 实例。

于 2020-08-19T19:46:22.510 回答
0

您可以尝试使用expect命令。我一直在努力解决类似的问题。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改用。

于 2020-12-11T08:31:59.750 回答