How Do I Run a Package?

New to AppleScript and not having fun trying to run a package (not look at its contents) from AppleScript inside a shell script using the osascript command. I’ve successfully gotten other AppleScript running in my shell script, but I haven’t a clue how to run a package. There must be a way to accomplish this task, but I’ve searched and searched for documentation on this, to no avail.

Here’s the AppleScript I’ve tried so far:

– First attempt:
run application “/myPath/MyPackage.pkg/Contents/Resources/ExeInsidePkg”

– Second attempt:
run application “/myPath/MyPackage.pkg”

– Third attempt:
tell application “Finder”
open package “MyPackage.pkg”
end tell

You have to use the BSD installer program to install packages.

sudo /usr/sbin/installer -pkg MyPackage.pkg -target /path/to/installation

At your terminal prompt type:

man installer

for more info.

try…

tell application "Finder"
	select file "MacHD:Users:yourname:Desktop:iChatAVBeta.pkg"
	open selection
end tell

Thanks for the replies. Greg, your code snippet works just fine when the path is passed like this in the shell script:
“Macintosh HD:Users:yourname:Desktop:iChatAVBeta.pkg”

But I get the path from a shell script variable that contains the path like this:
“/Volumes/Macintosh HD/Users/yourname/Desktop/iChatAVBeta.pkg”

and the latter doesn’t work. Any idea why? Any quick way to convert the first to the second? Again, I’m a total newbie to AppleScript.

Try doing a search for “POSIX and path” without the quotes in the OS X forum, it should turn up a lot of goodies. In the mean time, see if this helps…

tell application "Finder"
	set selection to POSIX path of "MacHD/Users/username/Desktop/iChatAVBeta.pkg"
	open selection
end tell