Thursday, December 14, 2017

#1 2017-11-27 07:34:57 am

timwiser
Member
Registered: 2017-11-27
Posts: 2

Creating notifications from scripts

Hi,

First of all hello to everyone.  Not only am I brand new to this forum but also to the whole world of Macs.  I work for an MSP here in the UK and am keen to get get started with some automation to help out our customers who use Macs as their daily drivers.

I've already baked some software installation scripts so we can automate the deployment of our key applications through our RMM product (ConnectWise Automate) but I'd like to put some wrapping around the scripts so that we inform the end user when the particular packages are installed.  I managed to make a popup message using a command like:

osascript -e 'display alert "Hello" with title "Message from Tim"'

Now that worked just fine.  However, if I run that through our RMM product, nothing happens.  The script completes fine but there's no message.  I'm assuming - coming from a Windows sysadmin perspective - that the script is not truly running as the logged in user but as a service account (whichever account the management agent is running as) and that's perhaps why the message does not appear on the logged-in user's desktop.

Does anyone know of a way that I could get a popup to appear?  Am I barking up the wrong tree using osascript?  Is there another way I could achieve the same goal?

Cheers
Tim.


Filed under: message, osascript, desktop, popup

Offline

 

#2 2017-11-27 08:34:41 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4452

Re: Creating notifications from scripts

Hi. Welcome to MacScripter.

It's not clear to me how you're running scripts, but just to point out that display alert doesn't have a with title parameter. I'd guess from the subject of your post that you mean display notification.


NG

Offline

 

#3 2017-11-27 08:42:00 am

timwiser
Member
Registered: 2017-11-27
Posts: 2

Re: Creating notifications from scripts

Hi,

Ah yes, sorry.  I've been playing with the commands and got them mixed up.

With regards running the script, we have a management agent installed onto Macs which collects inventory information, allows remote control and so forth.  It also allows the running of scripts.  What happens is that the agent is sent a shell command and then it executes it somehow.  That's as much as I know in terms of the Mac agent....  Maybe not terribly helpful information, I know.

Offline

 

#4 2017-11-28 05:55:57 am

Nigel Garvey
Moderator
From:: Warwickshire, England
Registered: 2002-11-20
Posts: 4452

Re: Creating notifications from scripts

I don't know what to suggest. On my High Sierra machine, this works fine as a shell command in Terminal:

osascript -e 'display notification "Hello" with title "Message from Tim"'

And these AppleScript script equivalents work both in Script Editor and as AppleScript applications:

Applescript:

display notification "Hello" with title "Message from Tim"

Applescript:

do shell script "osascript -e 'display notification \"Hello\" with title \"Message from Tim\"'"

I'd guess your problem's something to do with either the way the shell command's being passed to the agent, the way the agent's handling it, or something earlier in the script which is stopping it before the display notification command's reached.  hmm


NG

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)