【发布时间】:2020-11-15 21:25:55
【问题描述】:
我正在尝试使用 Automator 创建服务。
在运行 AppleScript 操作中,我有一个变量,它是一个字符串,其中每一行都是一个由换行符分隔的单词。像这样:
à
às
a
ante
ao
aos
após
aquela
当我尝试通过以下方式将其回显到终端时:
do shell script "echo " & (finalText as string)
我收到此错误:
The action “Run AppleScript” encountered an error: “sh: line 1: a: command not found
sh: line 2: à: command not found
sh: line 3: ante: command not found
...
sh: -c: line 30: syntax error near unexpected token `do'
sh: -c: line 30: `do'”
有什么想法吗?
【问题讨论】:
-
当您说“尝试将字符串变量回显到 Bash”时,您到底想要做什么?我问是因为在 Run AppleScript action 中使用
do shell scriptcommand 不会做很多事情,如果你所做的只是但是,从错误中回显一些文本字符串,您显然做的不止这些!无论如何,要摆脱 command not found 类型错误,请使用:do shell script "echo " & finalText's quoted form-- 至于 syntax error near unexpected token `do' 错误,没有看到所有代码,无法排除故障。 -
太棒了。
's quoted form成功了。请将此命令作为答案,以便我接受。
标签: applescript automator