Policy runs script successfully, but script doesn't show notification.

ahurwitz
New Contributor

Hi all, I am attempting to send users a notification Yo, a small tool that can make popup notifications, and running into an issue. If I run the script locally or call is specifically using terminal it will run properly and show the notification but on recurring check in when it is supposed to run the log shows a completed policy but the notification never appears.

Anyone have and ideas on what the issue could be?

The script I am using is as follows:

#!/bin/bash

#Checks if Yo is running and kills process if it is
function killYo (){
PID=`pgrep 'yo'`

echo $PID

if ps -p $PID > /dev/null 2>&1
then

   kill $PID
   sleep 10

else
    sleep 1
fi
}

#Sends Yo message
function sendMessage (){

#Variable for the logged in user name
currentUser=`who | grep console | awk '{print $1}'`
echo $currentUser

#Runs yo command as current user
su $currentUser -c '/Applications/Utilities/yo.app/Contents/MacOS/yo -t "Upgrade to macOS High Sierra" -b "Upgrade" -a /Applications/Self Service.app -i /Applications/Install macOS High Sierra.app/Contents/Resources/InstallAssistant.icns -d -s "Save your work session and upgrade" -n "Mandatory upgrade by 12/07/2018" -o "Postpone" -d'
}

killYo
sleep 5
sendMessage
0 REPLIES 0