I'm getting the following error client side when running a policy via the jamf binary:
Script Result: /private/tmp/SetARDAccess.sh: line 1: syntax error near unexpected token `newline'
/private/tmp/SetARDAccess.sh: line 1: `<?xml version="1.0" encoding="ISO-8859-1"?>'
The script runs fine locally on the clients, just not when passed via the jamf binary or run on a schedule.
Any idea why running the policy generates this xml error and how to resolve it? I don't see an errant newline anywhere. The script runs fine otherwise.
Server and clients are 7.1.
The policy changes a local admin (management account) password then runs a script (username removed for posting):
#!/bin/bash
# variables
user=<username here>
uid=/usr/bin/dscl . -read /users/$user UniqueID | awk '{print $2}'
ard_options="-activate -configure -clientopts -setreqperm -reqperm yes -setmenuextra -menuextra yes
-configure -users $user -access -on -privs -all -restart -agent -menu"
#
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart $ard_options
# set sharing pref
/usr/bin/defaults write /Library/Preferences/com.apple.RemoteManagement ScreenSharingReqPermEnabled -bool true
# change the uid if it's below 500; if not, leave it alone, then hide the under 500 users
if [ $uid -gt 500 ]; then
/usr/bin/dscl . -change /users/$user UniqueID $uid 499
/usr/sbin/chown -Rfv $user:staff /Users/<username here>
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool true
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array casper
/usr/bin/touch /Library/Receipts/org.company.adminpasschange
else if [ $uid -lt 500 ]; then
echo "nothing to do. user already has a <500 uid."
fi
fi
# check if a user is logged in, kill the loginwindow if there isn't, and do nothing if someone's logged in
currentuser=ls -l /dev/console | awk '{ print $3 }'
if [ "$currentuser" = "" ]; then
echo "Restarting loginwindow..."
/usr/bin/killall loginwindow
fi
exit 0