0
#/bin/bash
corr="apple"
echo $corr

osascript -e 'tell application "Messages" to send  "Did you mean "'"$corr"'" "  to buddy  "A"'

错误:

51:57: syntax error: A identifier can’t go after this “"”. (-2740)

如果我只是通过

osascript -e 'tell application "Messages" to send  "Did you mean $corr "  to buddy  "A"'

消息就像“你的意思是 $corr”

我已经尝试了将变量从 shell script 传递到 applescript中提到的所有内容

4

1 回答 1

1

在这里的最后有一个很好的解释和体面的例子。

基于此,我能够完成这项工作(使用 TextEdit,而不是 Messages):

 #!/bin/sh
rightNow=$(date +"%m_%d%B%Y")
osascript -e 'on run {rightNow}' -e 'tell application "TextEdit" to make new document with properties{name: "Date003.txt", text:rightNow}'  -e 'end run' $rightNow

我还发现我必须非常小心单引号和双引号。出于某种原因,我的键盘一直用弯引号代替普通引号。恼人的。

于 2015-05-22T16:18:04.563 回答