【发布时间】:2013-06-02 16:46:45
【问题描述】:
我正在尝试使这个脚本工作。这是一个Bash 脚本,用于获取一些变量,将它们放在一起并使用结果发送AppleScript 命令。手动将从变量to_osa 回显到osascript -e 后面的字符串粘贴到终端可以按我的意愿和期望工作。但是当我尝试组合命令osascript -e 和字符串to_osa 时,它不起作用。我怎样才能做到这一点?
the_url="\"http://stackoverflow.com/questions/1521462/looping-through-the-content-of-a-file-in-bash\""
the_script='tell application "Safari" to set the URL of the front document to '
delimiter="'"
to_osa=${delimiter}${the_script}${the_url}${delimiter}
echo ${to_osa}
osascript -e ${to_osa}
除了手动工作之外,当我将所需的命令写入脚本然后执行它时,该脚本也可以工作:
echo "osascript -e" $to_osa > ~/Desktop/outputfile.sh
sh ~/Desktop/outputfile.sh
【问题讨论】:
标签: macos bash applescript osascript