I made the changes to cli_test.php per your instructions, and strangely, it appears as if neither of those 3 items is triggering the error message. The "This script is only meant to run at the command line." message is now missing. If I revert back to the original file, though, that error message reappears. Strange!

Here's the output from the modified file:
Code:
Input: 56
Output:
Status: Invalid
Command: /usr/local/bin/php -q /home/blah/public_html/cacti/install/cli_test.php 56
For reference, and just to make sure I fully understood your directions, this is the full modified cli_test.php file:
Code:
#!/usr/bin/php -q
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2018 The Cacti Group |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| Cacti: The Complete RRDtool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* do NOT run this script through a web browser */
if (!isset($_SERVER['argv'][0])) {
die('<br><strong>ERROR 1 - This script is only meant to run at the command line.</strong>');
} elseif (isset($_SERVER['REQUEST_METHOD']) {
die('<br><strong>ERROR 2 - This script is only meant to run at the command line.</strong>');
} else if (isset($_SERVER['REMOTE_ADDR'])) {
die('<br><strong>ERROR 3 - This script is only meant to run at the command line.</strong>');
}
if ($argv !== false && sizeof($argv)) {
$value = intval($argv[1]);
print $value * $value;
}
And this is the full test.php file:
Code:
<?php
include('../include/global.php');
$path = '/usr/local/bin/php';
$input = mt_rand(2,64);
$cmd = $path . ' -q ' . $config['base_path'] .
'/install/cli_test.php ' . $input;
$output = shell_exec($cmd);
$expected = $input * $input;
$status = ($output != $input * $input) ? 'Invalid' : 'Valid';
echo "<html><body><h1>Input: $input<br>Output: $output<br>Status: $status<br>Command: $cmd</h1></body></html>";