2

我有一个 Shell 脚本,我需要在 MacOSX 10.6.X 上创建别名文件夹,所以我调用 osascript 使用以下代码来执行此操作:

Source="/Volumes/Test Project/Folder/SubFolder"
Destination="/Volumes/Test Project/Dest/"

/usr/bin/osascript -e 'tell application "Finder" to make alias file to POSIX file "$Source" at POSIX file "$Destination"'

此代码返回:

29:103:执行错误:Finder 出错:AppleEvent 处理程序失败。(-10000)

有没有人有办法解决吗?

4

2 回答 2

5

shell 不会替换$Source单引号字符串(例如整个AppleScript 命令)中的变量(例如)。解决方案:在命令周围使用双引号(这意味着您需要用反斜杠转义其中的双引号)。

/usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\""
于 2012-06-23T02:41:12.313 回答
3

有什么理由阻止您使用:ln -s "$Source" "$Destination"

于 2012-06-23T01:35:20.020 回答