I have to compare 2 xml files and generate a patch using php and Linux's diff command. Here's my code:
<?php
// script file location: /var/local/out/upload.php
// ...
// $templateName file location: /var/local/out/upload/example_word_template/word/document.xml
// $filename file location: /var/local/out/upload/example_word/word/document.xml
// $templateName value: upload/example_word_template/word/document.xml
// $filename value: upload/example_word/word/document.xml
$command = "diff /var/local/out/$templateName /var/local/out/$filename > /var/local/out/patch.patch";
exec($command);
echo($command);
?>
The browser outputs:
diff /var/local/out/upload/example_word_template/word/document.xml /var/local/out/upload/example_word/word/document.xml > /var/local/out/patch.patch
If I copy and paste the output and execute it directly in Linux, it runs just fine. But the script itself won't generate the patch file. What could be wrong?