Posted on 08-18-2020 04:14 AM
Hello! I am trying to use a script with AppleScript-built UI selector to give user ability to trigger some policy from Self Service.
I've tested this script locally in Pycharm CE and it's working pretty well. But when I'm trying to run it from a Self Service on MacOS Catalina, I am constantly getting: "2534:2654: execution error: Terminal got an error: A privilege violation occurred. (-10004)"
I've already checked and ensured that script is getting a correct credentials from variables so a problem isn't there..
Maybe someone can shed a light on this please?
Thanks in advance!
#!/bin/bash results=$( /usr/bin/osascript -e "display dialog " ENTER Your Password " default answer "" buttons {"Cancel","OK"} default button {"OK"}" ) theButton=$( echo "$results" | /usr/bin/awk -F "button returned:|," '{print $2}' ) PASSWORD=$( echo "$results" | /usr/bin/awk -F "text returned:" '{print $2}' ) USERNAME=${USER:-${USERNAME:-${LOGNAME}}} osascript <<END Set UNAME to ("$USERNAME") Set PASSW to ("$PASSWORD") set theHelpChoices to {"1", "2"} set theUserChoice to choose from list theHelpChoices with prompt "Please make your choice?:" default items {"1"} if theUserChoice is equal to {"1"} then tell application "Terminal" activate do shell script "/usr/local/bin/jamf policy -event XXXXX" user name UNAME password PASSW with administrator privileges end tell end if END
P.S. It's a shortened version of a script. Full one contains much more selection options to trigger different policies by a same way...