Computers are strange in that you can do really powerful things with them, but you have to know exactly what to say in order to get the desired result. Or maybe that's not so strange.

Anyway, like most servers, mine has PHP installed as an apache module. That means I can't invoke PHP, or a PHP script, from the command line (to the best of my knowledge.)

But like most problems, it's just a matter of finding the right way to ask:

lynx -dump http://www.digitalmediatree.com/somephpscript.php


does exactly what I want, although through a mechanism I would have never thought to use. Lynx is a text based web browser that can be used from the command line. The -dump argument just suppresses all output from lynx. And the URL given is the page for lynx to open. Of course that page is a PHP scirpt, so the result is that somephpscript.php gets run from the command line. Genius.

This means I can now invoke PHP scripts using procmail. Very nice. Before this I was calling Perl scripts that would then use HTTP::Request::Common and LWP::UserAgent to make a request to the PHP script.

That was a lot of work that is now unnecessary since I discovered the little lynx trick.
- jim 1-15-2005 10:47 pm




add a comment to this page:

Your post will be captioned "posted by anonymous,"
or you may enter a guest username below:


Line breaks work. HTML tags will be stripped.