Using PHP's exec() function (or the likes), how can you display terminal error output?

Posted by Miciah Amberong on Stack Overflow See other posts from Stack Overflow or by Miciah Amberong
Published on 2011-11-23T09:12:11Z Indexed on 2011/11/23 9:50 UTC
Read the original article Hit count: 136

Filed under:
|
|
|

Previous Reference

I am just wondering if there's a way (using PHP) to output the compile error information from the terminal to the browser?

For example: If you use this code to execute in the terminal...

gcc -o try try.c

...and assuming the "try.c" have some errors. The terminal will output something like this:

  • try.c In function 'main':
  • try.c:27 'x' undeclared (first use in this function)
  • try.c:27 (Each undeclared identifier is reported only once
  • try.c:27 for each function it appears in.)

Meanwhile, using this PHP code...

<?php exec("gcc -o try try.c"); ?>

The browser does not return any output like the terminal does. Is there a possible way direct or indirect that the error details that the terminal showed can be passed to the be displayed on a browser?

Thank you very much.

© Stack Overflow or respective owner

Related posts about php

Related posts about compiler-errors