I am trying to call a php script from a crontab sh script... I can get it to work if I hardcode each file, but I want to pass a variable to a single php file either from hardcoded calls in the sh script, or even better, by looping through an array.

Here is my script basics...

#!/bin/bash
cd  /home/account/myfolder;
php -q /home/account/myfolder/do_stuff.php?id=1; //calls the php but a $_REQUEST['id'] in the php is blank...
php -q /home/account/myfolder/do_stuff.php?id=2; //calls the php but a $_REQUEST['id'] in the php is blank...
php -q /home/account/myfolder/do_stuff.php?id=3; //calls the php but a $_REQUEST['id'] in the php is blank...

Needless to say, the script is not getting any url parameters from above.... how can I pass a value from a shell script to my php file or what is a better way to do this... I have about 60 ids I need to pass to the script...

Thanks!

I am trying to call a php script from a crontab sh script... I can get it to work if I hardcode each file, but I want to pass a variable to a single php file either from hardcoded calls in the sh script, or even better, by looping through an array.

Here is my script basics...

#!/bin/bash
cd  /home/account/myfolder;
php -q /home/account/myfolder/do_stuff.php?id=1; //calls the php but a $_REQUEST['id'] in the php is blank...
php -q /home/account/myfolder/do_stuff.php?id=2; //calls the php but a $_REQUEST['id'] in the php is blank...
php -q /home/account/myfolder/do_stuff.php?id=3; //calls the php but a $_REQUEST['id'] in the php is blank...

Needless to say, the script is not getting any url parameters from above.... how can I pass a value from a shell script to my php file or what is a better way to do this... I have about 60 ids I need to pass to the script...

Thanks!

:)

you need argc and argv
http://php.net/manual/en/features.commandline.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.