PDA

View Full Version : special character at cron job



jay2233
10-13-2009, 03:04 AM
Dear everybody,

I am trying to set a cron job, the command is as below:

wget http://www.XXX.com/abc.php?action=collect&siteid=1

After the system run it, I found that bluehost can only read "http://www.XXX.com/abc.php?action=collect", but lost &siteid=1 part

I also change the command as below, add "\" before the "&" character:

wget http://www.XXX.com/abc.php?action=collect\&siteid=1

After the modification, bluehost can read the "&" character, but output as below:

http://www.XXX.com/abc.php?action=collect\&siteid=1

Does anybody know how can I solve this problem?

Thanks a lot!

jay2233
10-13-2009, 09:04 AM
can anyone help me? Thanks!

felgall
10-13-2009, 11:08 AM
When the cron runs everything after the ? is iinaccessible anyway since jobs run from the command line have no access to $_GET

What you need to do is to replace the ? and & with spaces and then read in the values from $_SERVER['argv']

Adam
10-14-2009, 05:04 AM
*nix servers (what bluehost runs) interprets the & character as an actual system command. To fix this, include your entire URL in double quotes:


wget "http://www.XXX.com/abc.php?action=collect&siteid=1"