Calling a PHP document with SSH involves getting a variable

I have the following PHP document that I am invoking from a cron job.

if (is_file($docRoot . $row['cron_action_script_path'])) { system("php " . $docRoot . $row['cron_action_script_path'] . $row['params']); } 

However, I get the error Could not open input file: /path/to/file.php?params=1

But I go through the if is_file('/path/to/file.php') statement is_file('/path/to/file.php')

So it seems like there is a problem with including get variables on SHH calls for a PHP document.

Anyway, around? I need to be able to dynamically call my parameters in some way.

0
source share
3 answers
 if (is_file($docRoot . $row['cron_action_script_path'])) { $_GET['params'] = $row['params']; include $docRoot . $row['cron_action_script_path']; } 
+4
source

You make a call in php CLI and try to use the QUERY STRING data which is specific to the web server. You will need to either update the script to accept the parameters, or call it using a program such as lynx , curl or wget

So make a system call something like this:

 system("wget http://yourdomain.com/path/to/file.php?params=1 > /dev/null"); 

Then you should execute this script using a web server that will allow QUERY STRING .

EDIT:

Ability to use your variables: (Please note that after compilation, a slash may be required.

 system("wget http://yourdomain.com" . $row['cron_action_script_path'] . $row['params'] . " > /dev/null"); 
+3
source

Try is_readable instead of is_file . A file may exist without reading by your current user.

However, such options will not work. You cannot use $_GET variables on the command line. See how PHP expects and processes command line arguments .

+1
source

All Articles