1

I have this PHP code:

ini_set('display_errors', 1);
ob_start();
passthru('/usr/bin/python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt');
$output = ob_get_clean(); 
echo $output;


$message = exec("/usr/bin/python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt");
print_r($message);

$command = shell_exec('python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt');
echo $command;

$output=shell_exec('python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt');
echo "<pre>$output</pre>";


$command = escapeshellcmd('python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt');
$output = shell_exec($command);
echo $output;

exec('sudo -u www-data python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt');

system("cd /usr/lib/cgi-bin && sudo python3 /home/domains/mydomain.pl/public_html/a.py /home/domains/mydomain.pl/public_html/code2.txt");

I would like PHP to: 1. launched the a.py script 2. returned the result which the console will display from a.py and display it in the web browser.

At the moment, nothing is showing up. I do not have any error message or warning.

Does anyone know what is wrong in the above code?

My server allows running scripts with the console

3
  • Hi again =) call error_reporting(E_ALL); after ini_set to be sure that you display all types of errors, especially the fatal ones, also don't use it (i.e. ini_set and error_reporting) in production environment, should only be used in your development machine. Since it will show errors to your users which is not professional plus it is considered a security flaw. Commented Nov 5, 2018 at 0:00
  • Thank you for your response. I;m adding error_reporting (E_ALL); but it's nothing gave. I not see any messages from the console or any errors Commented Nov 5, 2018 at 0:16
  • Got it you probably have an error thrown by the command, and in order to show this error, you need to append this string '2>&1' at the end of the command you pass to your functions (e.g. passthru). See this ref: PHP exec() not returning error message in output. Commented Nov 5, 2018 at 0:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.