Embed binaries in applescript

Hi All,

I have an applescript that relies on command line binaries when executed. I would like to make this script portable to different users so I embedded the binary file in the the scripts resources folder and call it from there. Unfortunately the binary calls on another perl script when executing and that can’t be located by the script. I have tried to also embed the other binaries but I don’t seem to be able to make it work.

Here’s the script:

set exiftool to quoted form of POSIX path of ((path to me as string) & "Contents:Resources:exiftool")

set thefile to quoted form of POSIX path of (choose file)

do shell script exiftool & space & thefile

The error I get is this:
error “Can’t locate Image/ExifTool.pm in @INC (@INC contains: /Users/nikj/Desktop/exif_test.scptd/Contents/Resources/lib /Library/Perl/Updates/5.10.0 /System/Library/Perl/5.10.0/darwin-thread-multi-2level /System/Library/Perl/5.10.0 /Library/Perl/5.10.0/darwin-thread-multi-2level /Library/Perl/5.10.0 /Network/Library/Perl/5.10.0/darwin-thread-multi-2level /Network/Library/Perl/5.10.0 /Network/Library/Perl /System/Library/Perl/Extras/5.10.0/darwin-thread-multi-2level /System/Library/Perl/Extras/5.10.0 .) at /Users/nikj/Desktop/exif_test.scptd/Contents/Resources/exiftool line 30.
BEGIN failed–compilation aborted at /Users/nikj/Desktop/exif_test.scptd/Contents/Resources/exiftool line 30.” number 2

Any help would be greatly appreciated.

Thanks,
Nik

Hi,

I managed to solve this problem myself so I thought I’d post it back incase it helps anybody in the future. The problem was that I needed to include the path to the binary and its dependents in my environment path.

set thefile to quoted form of POSIX path of (choose file)

set myenv to quoted form of POSIX path of ((path to me as string) & "Contents:Resources")

set exiftool to quoted form of POSIX path of ((path to me as string) & "Contents:Resources:exiftool")

set meta_data to (do shell script "PATH=$PATH:" & myenv & "; " & exiftool & space & thefile) as text

Hope this helps,
Nik