Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PHP shell script in Automator MacOS Monterey no longer works

MacOS Monterey no only seems to support PHP within Automator.

You can run PHP from the Terminal without error (if installed via Brew) but running PHP scripts from Automator in a "Run Shell Script" gives the error

php: command not found

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

In the Terminal, running

which php

Results in /usr/local/bin/php.

Interestingly the newer Shortcuts app supports PHP scripts. Any ideas how to get Automator working with PHP again?

>Solution :

This happened because your path to PHP is in /user/local/bin and that it is not part of the PATH used by Automator anymore, as it seems.

In an unmodified Automator "Run Shell Script" step, the PATH variable contains

/usr/bin:/bin:/usr/sbin:/sbin

So, the simple way to fix it is to add /usr/local/bin to the PATH in your "Run Shell Script".
In order to do that, you juste have to add a first line in the said task that would consist of:

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

From there on, Automator will be able to find the PHP binary correctly, as it was before.


More information on what is the PATH variable and what it does mean in Linux and Unix (Mac OS is a Unix-like distribution) can be found here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading