Community & Support

PHP Exec executes some commands, but not others

I'm trying to get the difference between 2 files on my Debian system.

<?php
$output
=`diff path/to/file1 path/to/file2`;
echo
"<hr>".$output."<hr>";
?>

Gives a page with "<hr><hr>".

However, this:

<?php
$output
=`ls -la path/to/files/`;
echo
"<hr>".$output."<hr>";
?>

Gives me a listing of the directory as expected.

Do the executables need to be registered somewhere?

Comments

Does your apache user have

Does your apache user have the necessary permissions to access the files and to execute the diff command?

Thanks, Criznach.

Odd.

<?php
$output
=`diff path/to/file1 path/to/file2>/tmp/difffile`;
echo
"<hr>".$output."<hr>";
?>

Produces the file /tmp/diffile with the 'diff' output.

But I would have expected the following:

<?php
$output
=`diff path/to/file1 path/to/file2`;
echo
"<hr>".$output."<hr>";
?>

to produce the contents of the diff file as the $output.

nobody click here