Kaseya Community

expression in procedure for macOS

This question is not answered

I can't seem to get this to work because of quotes:

"osascript -e 'tell app ''loginwindow'' to «event aevtrrst»'"

how to handle this?

All Replies
  • This may not just be an issue with macOS in .27.  

    I'm seeing issues with quotes in a number of procedures since upgrading

  • I'm on SaaS Kaseya VSA agent 9.5.0.16

    My solution was to make a bash file with the script and then make the Agent run it.

  • I used this code to make it happen:

    In my test-mac.sh file I wrote all the script as if I run it directly in Terminal. No more complex expression in Kaseya VSA Procedure editor.

  • You need to bear in mind that executing a command as system on macOS (and any *nix OS) it is in the context of root already.  As such the root user does not have the same environment as any other user so most of your commands will fail if they require access to config settings from a ~/.config file or if the command is NOT in the root /bin path.

    The root user does not use /usr/... items at all.

    If you want a command to execute on macOS as it would from your login shell then it must run as user with the credentials set and accessed by usecredential().  Also the user that is running the commands must have been setup with those commands.  

    For example:

    The logged in user installs .net core & powershell core

    the user referenced by usecredential() can:

    explicitly run both by using the full /usr/local/... or /usr/share/... commands but may not have any of the settings used by the logged in user.

    probably does not have either in it's envioronment path

    the root user

    knows nothing about either and while it can explicly invoke either from the /usr/... path the commands will fail because it does not have any of the configuration information for either one.