【发布时间】:2020-12-09 01:47:48
【问题描述】:
我想使用“询问对话”命令立即传递问题。我正在尝试自动化启动终端和运行“询问对话框”的过程。每当我的 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 >
如果不能立即传递问题,是否可以向终端发送击键?
【问题讨论】:
-
我猜你想要
expect(一种建立在TCL之上的脚本语言,专门用于自动化其他程序,读取它们的输出并写入它们的输入) ) - 尽管这与您的标题所要求的完全相反。尽管您可能想要一个heredoc,以便能够将文本写入ask的标准输入?很不清楚你真正想要什么,所以不清楚如何回答。 -
...当您说“通过 bash 命令传递文本”时——具体来说,应该通过 which bash 命令传递 which 文本?
-
备份:当您说“通过一个问题”时,您是否希望将您的问题写入
ask命令? (如果是这样,你想要的可能是一个heredoc:ask <<EOF,然后是你的问题文本,然后是EOF)。 -
太棒了——听起来像heredoc真的是你想要的,那么;我们确实有几个问答条目描述了如何做到这一点。
-
查看How do I provide input to a C program from bash? 的答案——请注意,虽然这个问题涉及到很多 C 特定的细节,但答案非常笼统。
标签: bash shell command-line terminal ask-cli