I get errors running this shell script

I am new macs and new to this forum.

I was hoping someone who can point me in the right direction:

I am writing a shell script to find a file if found return code 64 or just exit

I am typing this in the Apple script editor but keeps giving an error.

#!/bin/sh

if [-f /Applications/myProgram.app/Content/Database/myData.4DD]; then
exit 64
fi

exit 0

:frowning:

Welcome to the forum.

You can execute a shell script from AppleScript Editor like this:

set xxx to do shell script "echo 'hi there'"

You should also read about the proper way of escaping shell scripts in AppleScript.

When you know bash, you would have known that bash is very strictly how to use spaces. An if statement should therefore look like this:

do shell script "#!/bin/sh
if [ -f /Applications/myProgram.app/Content/Database/myData.4DD ] ; then
    exit 64
fi
exit 0"

You know that when you exit with another number than zero AppleScript will throw an error?

thanks bazzle

I am using Iceberg to create a metapackage. This script will help determine if the installation of the package goes through or not.

I will test it out and let you know how that goes.

:slight_smile:

This is more convenient at times: ( I had forgotten about exit 0, I have used echo >/dev/null lately. ) :slight_smile:

my_command_with_a_variable_uninteresting_exitcode_that_are_hard_to_control || exit 0