Reputation: 71
I have a web server being hosted on a Raspberry Pi B+, running Raspbian. I always have a php "shell" that i can use, but it seems that mine might be messed up somehow. It is an html textarea, with the name="phptorun"
, and the action file just does eval($_POST['phptorun']);
Since I just have my RPi tucked under a table with no display, I use my phone alot to access the command line.
My question:
When i run something like system("ls");
i get output and the contents of the working directory is displayed. I am working on a C "compiler" (it just uses the command line gcc
) but when i do system("gcc");
i get no output at all. i know that the command gcc does put out output, because i have done it before on a different computer.
So why is system("gcc");
not working?
And if gcc isnt installed, wouldnt i get output, just an error?
Upvotes: 0
Views: 63
Reputation: 25401
You need to get more information, it's possible that gcc
outputs something to the STDERR
for example, which you're missing when you use the system
function.
Better try to use the exec
function:
exec("gcc 2>&1", $output, $return_code);
Explanation:
gcc 2>&1
redirects STDERR
output to the STDOUT
STDOUT
is captured into the $output
variable$return_code
Upvotes: 1