Reputation:
I've been trying to run this php code on CentOS:
<?php
$command = "diff file1 file2 > file3";
exec($command, $output, $error_code);
if ($error_code != 0) {
echo "Error: $error_code";
}
?>
And it always echoes "Error: 1". Error 1 is "Operation not permitted" http://www.pegasoft.ca/resources/boblap/99_b.html. It looks like apache has no permissions to do certain things, right? How can I fix that?
Upvotes: 1
Views: 2448
Reputation:
Oh >____<
I had this line at the end of my script:
exec("rm -f /var/local/out/upload/example_word/word/diff.diff");
The file was created and then deleted... That's why I could never see it. Sorry.
Upvotes: 1
Reputation: 2451
I think it's because you're not using the right command. You're running $command like in a terminal, so you need to add a command indicating that you have permission. I think that on CentOS it's su. In Ubuntu, for example, you would do sudo -command-.
So try to add su before diff.
Edit:
You should check here for proper usage of su: http://wiki.centos.org/TipsAndTricks/BecomingRoot
Upvotes: 1