Simon icon Simon
Flexible server monitoring

Simon 5 is coming soon!

Simon version 5 is currently in beta testing. It is a massive update, introducing a much-requested feature: syncing the Simon data between multiple Macs, plus a Simon Status service, a Link Checker filter, improved Find filter, iMessage and Speak Error notifiers, a new app icon, and much more.

Important: please note that Simon 5 requires a minimum of macOS 10.12 (Sierra), and will be a paid upgrade from Simon 4 after the beta. Purchasers since September 1, 2020 automatically get a version 5 license (that also works in previous versions).

Read the blog for details.

Return Array from Script to Send via Email

I wrote a PHP script to check if multiple specific JSONs are the way they should be, with valid values.
The result of this script is an array with the error data - I need to send this error data by email.

In other words: How can I pass an array as a result of a service to a notifier (email)?

Thank you!
Jonas

David Sinclair's picture

Re: Return Array from Script to Send via Email

Hi Jonas,

You need to convert that array to a single string (by looping over it and concatenating to a string), which you can then echo to the script output.

You can't output that string as an error message, but you could make the script result in an error via exit(99); or similar, and look at the output text instead of the error in your notifier.

Re: Return Array from Script to Send via Email

Hi David

Thank you very much for your response! This is very similar to what I've been trying to do, though I couldn't find a way to get the output text into the notifier. Is that one of those variables I can insert? If yes, could you inform me which one it is? I can't seem to find it and have been trying for hours to get this to work.

Thank you very much!
Jonas

Re: Return Array from Script to Send via Email

David, I found it! For anyone else reading this with the same issue of not knowing how to do it - in your service print/output the data you would like to send via a notifier. In the notifier choose the service that outputs the data and use the variable {ServiceResponseText}, which contains the mentioned data of the output from the service.

Cheers!
Jonas

David Sinclair's picture

Re: Return Array from Script to Send via Email

Hi Jonas,

Yep, that's the one.