[CS-FSLUG] Shell command in PHP script

K Montgomery keltik at albany.edu
Fri Mar 26 13:17:59 CST 2004


On Fri, 2004-03-26 at 09:23, Josiah Ritchie wrote:
> I asked this awhile ago and someone had an answer.
> 
> I want to run a shell command inside a php script. How can I do this.
> I thought the answer was to put a ! in front of the command. An
> example would be great.
> 
> Thanks,
> JSR/

I think you could just use the system() function, as in:

system("ls -l /tmp");

To get the output of the command, use the backticks operator:

$newvariable = `ls -l /tmp`;
echo $newvariable;

- Kathy






More information about the Christiansource mailing list