Feed POST/GET Data to Lynx Via Command Line

I use cron a lot in conjunction with PHP to manage my jobs on the server. So, as many PHP programmers know, the lynx text-based browser is an invaluable tool. You may encounter a situation where you’ll need to feed data from one PHP file to another via GET or POST. This code grabs dynamic POST Data from a URL and feeds it to another page using lynx -post_data switch.

lynx -dump "http://my.server.com/post/data/generator.php" | lynx -dump -post_data "http://my.server.com/post/data/consumer.php"

The page http://my.server.com/post/data/generator.php will create a data package that can be consumed by PHP via the regular request variables (e.g. $_GET and, in this case, $_POST). For example, if you wanted to provide a list of e-mails to be fed to your consumer.php page, you could build your string to be something like:


On the consumer.php side, it would look like (via print_r($_POST['notify_emails'])):

    [0] => johnd@server.com
    [1] => ronaldcs@server.com
    [2] => mikes@server.com

Note that -get_data could be used in place of -post_data if you’re more prone to use $_GET.