posix_spawn no such file or directory - launchctl as user

Kevmo
New Contributor II

My Google-foo is failing me.  Although my script works to trigger the Jamf helper window - I get 'posix_spawn(): 2: No such file or directory' <-- And as far as I can tell it's because i'm trying to call launchctl -but - can't figure it out.  Is this an error I should be concerned about?

JHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"

LOGGED_IN_USER=$(stat -f%Su /dev/console)
LOGGED_IN_UID=$(id -u "$LOGGED_IN_USER")
echo $LOGGED_IN_USER

WELCOME=$("$JHELPER" -windowType utility -windowPosition lr -heading "Urgent message from Mac Desktop Services."  -alignDescription natural -description "An urgent OS update is needed on your system. 
Please run sofware update at the end of the day 
(Apple Menu --> System Settings --> General - Software Update) 
and install Ventura macOS 13 updates to bring your system to 13.6 if it is not already.  

Please do not click Upgrade to Sonoma, only updates for macOS 13 Ventura

" -button1 "Go to updates" -button2 "Dismiss" -cancelButton "2")

if [ "$WELCOME" == "0" ]; then
      /bin/launchctl asuser "$LOGGED_IN_UID"  "$LOGGED_IN_USER" 
      osascript -e 'do shell script "open x-apple.systempreferences:com.apple.Software-Update-Settings.extension"'
      echo "Clicked to update"
      exit 0
else
      echo "user chose dismiss"
      exit 1
fi

 

 

 

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

@Kevmo No need to try calling as an osascript, just do the open:

 

open 'x-apple.systempreferences:com.apple.Software-Update-Settings.extension'

You might also want to look at this article on running a command as another user for best practices on that: https://scriptingosx.com/2020/08/running-a-command-as-another-user/

 

View solution in original post

1 REPLY 1

sdagley
Esteemed Contributor II

@Kevmo No need to try calling as an osascript, just do the open:

 

open 'x-apple.systempreferences:com.apple.Software-Update-Settings.extension'

You might also want to look at this article on running a command as another user for best practices on that: https://scriptingosx.com/2020/08/running-a-command-as-another-user/