Quantcast
Channel: Running a Python script from PHP - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by the for Running a Python script from PHP

$
0
0

If you want to know the return status of the command and get the entire stdout output you can actually use exec:

$command = 'ls';exec($command, $out, $status);

$out is an array of all lines. $status is the return status. Very useful for debugging.

If you also want to see the stderr output you can either play with proc_open or simply add 2>&1 to your $command. The latter is often sufficient to get things working and way faster to "implement".


Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>