2
我有一個非常簡單的腳本run.php
了shell_exec sed的-i寫文件
<?php
shell_exec('/var/www/html/insert.sh');
?>
insert.sh
#!/bin/bash
sed -i '/blah/ r file1.txt' config.xml
我對Apache日誌獲得以下錯誤:
sed: couldn't open temporary file ./sedV5qH6N: Permission denied
sed: couldn't open temporary file ./sedBS3zO6: Permission denied
sed: couldn't open temporary file ./sedR4Nw3O: Permission denied
即使我給了它apache
業主的全部許可。我該如何糾正錯誤?
我可以告訴'sed'使用不同的臨時工作目錄嗎?像'/ tmp' – Satish
'chown apache:apache/var/www/html'它的工作原理! – Satish
我不這麼認爲,如果你想使用-i(就地)選項,但你可以做一些像「sed'/ blah/r file1.txt'config.xml> /tmp/config.xml && mv /tmp/config.xml config.xml「。請注意,在這種情況下存在明顯的競爭條件。 –