Ich muss 2 XML-Dateien vergleichen und generieren einen Patch mit PHP und Linux Diff-Befehl. Hier ist mein Code:Verwenden von Diff in Linux mit PHP exec-Funktion
<?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);
?>
Die Browser-Ausgänge:
diff /var/local/out/upload/example_word_template/word/document.xml/var/local/out/upload/example_word/Wort/Dokument .xml> /var/local/out/patch.patch
Wenn ich die Ausgabe kopiere und einfüge und sie direkt in Linux ausführe, läuft sie gut. Aber das Skript selbst wird die Patch-Datei nicht erzeugen. Was könnte falsch sein?
Die Ausgabe war "array (0) {} int (1)" –
@wilsonsilva Es gab einen Fehler. – alex
Ich denke, es ist Operation nicht erlaubt :) http://www.pegasoft.ca/resources/boblap/99_b.html – Catalin