Script Error

stretchmonster0
New Contributor

Good day everyone,

I'm hoping that I can get a second set of eyes on this script. It is designed to check the status of Find My Mac, and works find locally, but it is erroring out when I run it through a Jamf Policy.

Here is the script:

!/bin/bash

this script will check the status of Find My Mac. If it isn't running, it will end, otherwise it will execute the AppleScript below that

fmmStatus=$()

if [[ "$fmmStatus" = 0 ]]; then

echo "Find My Mac Not Running"

exit 1

else

osascript -e "tell application "System Events" to display dialog "Hey there! IT requests you please stop using "Find My Mac" on this MacBook Pro as it has been found to interfere with our Mobile Device Management security settings.
Please go to System Preferences > Apple ID > Find My Mac and disable the checkbox for this feature.
If you have any questions please reach out to IT and we can help you out. Thanks!"

fi

exit 0

I receive the error message of -> Script result: 110:115: syntax error: A identifier can’t go after this “"”. (-2740)

Any help would be appreciated it.

Thank you.

1 ACCEPTED SOLUTION

skeenan07
New Contributor III

You need to escape the quotation marks around Find My Mac. See the following:

osascript -e 'set message to "Hey there! IT requests you please stop using \"Find My Mac\" on this MacBook Pro as it has been found to interfere with our Mobile Device Management security settings.

Please go to System Preferences > Apple ID > Find My Mac and disable the checkbox for this feature.

If you have any questions please reach out to IT and we can help you out. Thanks!"

tell application "System Events" to display dialog message'

Also, when you add a script to your post, it is easier to read when you wrap it in ```

View solution in original post

2 REPLIES 2

skeenan07
New Contributor III

You need to escape the quotation marks around Find My Mac. See the following:

osascript -e 'set message to "Hey there! IT requests you please stop using \"Find My Mac\" on this MacBook Pro as it has been found to interfere with our Mobile Device Management security settings.

Please go to System Preferences > Apple ID > Find My Mac and disable the checkbox for this feature.

If you have any questions please reach out to IT and we can help you out. Thanks!"

tell application "System Events" to display dialog message'

Also, when you add a script to your post, it is easier to read when you wrap it in ```

stretchmonster0
New Contributor

Hi Skeenan07,

 

Apologies on the late response.  Thank you very much for the help.