• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

Calling bash script from php

mcplaayer

n00b
Joined
Dec 29, 2004
Messages
59
Hey guys, I've got a bash script that I need to run and collect output from, except that it needs to be called from an php enviornment.

I would like to collect the output from this bash script(stdout) and store it into an array in php.

Anybody know how to do this?

The shell call would be:

echo `get-All.sh $prod $type`;
 
Call the script with exec() making sure to give it an array to populate with the output.
 
If my Apache server isn't set up to allow exec calls, would I result in a blank page? Because that's what just happened when I tried using exec...

Maybe I could use system() instead.
 
Well what did you do with the resulting output from the exec() command? If you pass it to an array like you were talking about, you could do something like...

Code:
<?php

echo '<pre>';
print_r( $output ); // where $output is the array passed to exec()
echo '</pre>';

?>

...to test and see what the output is.

Or you could do something like shell_exec() with the echo call and just output everything as one big chunk, rather then an array.
 
Well I had other content on this particular page that did not display...
I'll give shell_exec a shot.
 
Hey guys,

Now I have to do the same thing in Perl. Is there a Perl equivalent of the exec() call in PHP that also does the nice formatting and auto array storage?

Thanks
 
Back
Top