Open celorodovalho opened 6 years ago
I must to do that in function "execute_command":
// Command execution
function execute_command($command) {
$descriptors = array(
0 => array('pipe', 'r'), // STDIN
1 => array('pipe', 'w'), // STDOUT
2 => array('pipe', 'w') // STDERR
);
$preCommand = [
'export HOME=/home/XXX'
];
$commands = [
'php' => '/opt/php71/bin/php',
'composer.phar' => '/opt/php71/bin/php /home/XXX/bin/composer.phar',
'composer' => '/opt/php71/bin/php /home/XXX/bin/composer.phar',
];
foreach ($commands as $key => $cmd) {
$command = preg_replace('/(^|\s)('.$key.')($|\s)/i', '$1'.$cmd.'$3', $command);
}
$preCommand = implode(' && ', $preCommand).' && ';
$process = proc_open($preCommand.$command . ' 2>&1', $descriptors, $pipes);
if (!is_resource($process)) die("Can't execute command.");
// Nothing to push to STDIN
fclose($pipes[0]);
$output = stream_get_contents($pipes[1]);
fclose($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[2]);
// All pipes must be closed before "proc_close"
$code = proc_close($process);
return $output;
}
I have a hostgator shared account. In my .bashrc i have:
In webconsole, when I try to run:
I got:
or when I try to run:
I got: