Passing get variables to a script via cron job?

I’m trying to run a cron job that passes a get variable like so:

/usr/bin/php /home/script.php?code=xyz

I’m having trouble getting this to work, but the instructions for the script say it should work just fine.
I can run the script through command line, but adding ?code=xyz causes file not found errors. Is there something I need to enable first?

/usr/bin/php /home/script.php xyz


<?php

$argv = $_SERVER['argv'];
print 'You entered: ' . $argv[1];

You may find this post useful: http://www.sitepoint.com/forums/showthread.php?t=532378&highlight=cli

as well as: http://us.php.net/features.commandline

I can’t edit the script, any other ways to get around it?

umm…why can’t you edit the script? And the only way to get around it is to run it from a browser, a url which I do not advise.

You’ll have to edit the script, any possible workaround would be inefficient and alot more work.

Do what drupal does, use lynx.


/usr/bin/lynx -source http://example.com/cron.php?arg=xyz

A better approach would be to make a proxy script thats ran instead.


<?php

$_GET['code'] = $_SERVER['argv'][1];
require_once '/home/script.php';