Message Boards Message Boards

GROUPS:

[SOLVED]: How do I run a WolframScript using MacOS Automator?

Posted 7 days ago
120 Views
|
3 Replies
|
1 Total Likes
|

I need to run some WolframScripts on a schedule so I am trying to set up MacOS Automator to run them but I am having issues. Any help would be greatly appreciated.

Here is what I have so far:

send-test-email.wls: #!/usr/bin/env wolframscript Needs["ww`"]; sendGmail["mike.besso@gmail.com", "test subject", "test body"];

This script works (after making it executable of course).

Since I could not figure out how to kick this script off with Automator, I created a shell script which I can kick off with Automator:

send-test-email:

#!/bin/zsh
wolframscript -file send-test-email.wls

This works as well from a terminal.

But, when I try to "Run Shell Script" from Automator, I get an error:

enter image description here enter image description here

I spent an hour searching the web and learned:

  • I might be able to use chrontab, but that seems more complicated than what I need
  • A 2011 discussion on this topic is no longer available
  • Many years ago, there was an Automator add-in for Wolfram, but I cannot find it

Have a great week.

3 Replies
Posted 7 days ago

Figured this out... but it took a bit more caffeine. It would seem that Automator does not search the path. We can argue the wisdom of this. I can see both sides of the argument.

Nonetheless, it would be great if the documentation (on Apple's end this time) was a bit clearer.

So, in the end, this works:

enter image description here

Hi Mike,

A guess. Automator does not create an interactive shell so .zshrc is not sourced, so wolframscript is not in the PATH. Try adding source ~/.zshrc to the Automator script before executing the shell script.

Posted 7 days ago

@Rohit:

Thank you for your suggestion. You are, of course, correct. But, there is a but. Automator does not keep the path setting from the .zsh (or .zshrc). From what I can tell, I'm not the only one who has run into this.

Following your lead, I can put the following at the top of the "Run Shell Script":

export PATH=/usr/local/bin:$PATH

thanks

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract