Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top