Hey All -
I'm trying to get the icon that we utilize for our Self Service portal (located at /Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images) to display when calling a custom "Display Dialog" AppleScript popup from within a Bash script.
Current code looks like:
#!/bin/bash
#get logged in user info
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
loggedInUserUID=$(id -u "$loggedInUser")
userPopup="set input to \\
(display dialog \\
\\"blah blah blah\\" \\
with title \\"xxxxxx\\" \\
with icon POSIX file \\"/Library/Application Support/com.jamfsoftware.selfservice.mac/Documents/Images/brandingimage_asTest.icns\\")"
prompt=$( /bin/launchctl asuser $loggedInUserUID sudo -u "$loggedInUser" /usr/bin/osascript -e "$userPopup" )
which errors out with this:
execution error: Can’t make file "Macintosh HD:Library:Application Support:com.jamfsoftware.selfservice.mac:Documents:Images:brandingimage_asTest.icns" into type number or string. (-1700)
However, if I copy the same file to the Desktop and run this code snippet, it works perfectly:
#!/bin/bash
#get logged in user info
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`
loggedInUserUID=$(id -u "$loggedInUser")
userPopup="set input to \\
(display dialog \\
\\"blah blah blah\\" \\
with title \\"xxxxxx\\" \\
with icon POSIX file \\"/Users/<username>/Desktop/brandingimage_asTest.icns\\")"
prompt=$( /bin/launchctl asuser $loggedInUserUID sudo -u "$loggedInUser" /usr/bin/osascript -e "$userPopup" )
I should also mention I have tried both methods without specifying POSIX file and utilizing normal AppleScript method and the same behavior occurs.
Does anyone know a way to make this work while utilizing a non-user filepath? Or is this just a pitfall of using apple script?