Forum Moderators: coopster
I am trying to use php's exec() or system() to execute a shell script that I wrote.
exec and system() work fine with a simple command like ls, but nothing happens when I point it at the shell script.
The shell script works fine from my shell login. Can't figure out what tho problem is. Is php just incapable of running shell scripts?
Thanks for your help!
Erik
Return ValuesThe last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function.
To get the output of the executed command, be sure to set and use the output parameter.
system
system() is just like the C version of the function in that it executes the given command and outputs the result.The system() call also tries to automatically flush the web server's output buffer after each line of output if PHP is running as a server module.
Return Values
Returns the last line of the command output on success, and FALSE on failure.
passthru
The passthru() function is similar to the exec() function in that it executes a command. This function should be used in place of exec() or system() when the output from the Unix command is binary data which needs to be passed directly back to the browser. A common use for this is to execute something like the pbmplus utilities that can output an image stream directly. By setting the Content-type to image/gif and then calling a pbmplus program to output a gif, you can create PHP scripts that output images directly.
which one? I don't know ;)