views:

940

answers:

4

Hi,

I'm tempted by Automator.app's ability to create contextual services in Mac OS X Snow Leopard. I would like to create some keyboard accessible shortcuts to manipulate text snippets by calling a shell script. However, Automator only suggests bash, Perl, Python and Ruby (among others) to allow this. But, since PHP also ships with Mac OS (and, to be honest, it's the only scripting language I fully master), I wonder why I can't run a PHP shell script.

Can this be done?

Thanks for your help, Roel

+4  A: 

This is just a hack, but how about creating a python, or ruby or perl or bash script that calls php command-line interpreter with the php script you want to execute?

For instance in bash would be as simple as this:

#!/bin/bash   
php myscript.php

Now save it, give it permission for execution:

chmod +x my_bash_script.sh

And voilá. Automator can now run the bash script, which calls the php script.

rogeriopvl
+1  A: 

Automator has a "Run Shell Script" Action just add it to your workflow and follow the instructions on the bottom left.

+2  A: 
dbr
A: 

The list of shells that Automator supports is in

 /System/Library/Automator/Run\ Shell\ Script.action/Contents/Resources/Shells.plist

You can follow this guy's instructions to add an entry for /usr/bin/php. You may want to copy the .action file to ~/Library/Automator first, and work on the copy instead.

Of course, it's probably easier to just wrap it in a bash script, as others have suggested.

JW