문제

I have a Shell Script where I need to create aliases folders on a MacOSX 10.6.X so I call osascript to do it with the code below:

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"'

This code returns:

29:103: execution error: Finder got an error: AppleEvent handler failed. (-10000)

Does anyone have a solution?

도움이 되었습니까?

해결책

The shell doesn't substitute variables (e.g. $Source) inside single-quoted strings (e.g. the entire AppleScript command). Solution: use double-quotes around the command (which means you need to escape the double-quotes inside it with backslashes).

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

다른 팁

Any reason keeping you from using: ln -s "$Source" "$Destination"?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top