I have a command line test script that runs locally OK, but when I try to run it on my host (Bluehost) through ssl (using Putty) it fails, but doesn't throw an error.
I've checked the error logs and there is nothing there to indicate a failure and I have turned on E_ALL errors there.
On my local wamp server this runs fine and outputs all the prompts:
1. environment imported
2. About to execute!
3. Got instance
4. Success
5. Finished executing!
When I run this over putty at my host it outputs only the first two lines. 1. environment imported 2. About to execute!
This is the script (joomla 3.4.5):
<?php
// Initialize Joomla framework
const _JEXEC = 1;
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
require_once JPATH_BASE . '/includes/framework.php';
echo "1. Environment imported\n";
class Test extends JApplicationCli
{
public function doExecute()
{
echo "4. Successful execution\n";
}
}
echo "2. About to execute\n";
$test = JApplicationCli::getInstance('Test');
echo "3. Got instance\n";
$test->execute();
echo "5. Finished executing!\n";
?>
I have tried running this with different variations of the command line:
php jwjtest.php
php54s -c ~/public_html/php.ini ~/public_html/cli/jwjtest.php
I have also surrounded the line that executes 'getInstance' with 'try' and 'catch' but no error is caught.
Any help would be welcome. Thanks!
Note: I am posting this on the joomla stackexchange (I already tried the regular stackexchange, but this seemed to be a more relevant forum)
Note: I've tried triggering run time errors and they seem to work fine outside the cli class, but inside the doExecute method nothing happens (as if no code inside there is being executed), but something must be erroring out because the last echoe'd comment ('finished executing') never gets executed.
php jwjtest.php
and alsophp54s -c php.ini jwjtest.php
(which I use in a cron job) ... how do I run php5-cli or test for its availability? Thanksphp54-cli
to run the script and all was well ; much appreciated (I'm not sure how to mark a comment as answering the question on stackexchange)php jwjtest.php
instead ofphp54-cli jwjtest.php