1

i try to make this:

<?php
error_reporting(E_ALL);
echo "<HTML><BODY>";
exec("echo Hallo > /tmp/testtt.txt", $output, $retval);
echo "Rückgabe mit Status $retval und Ausgabe:\n<br/>";
foreach($output as &$s){
       echo $s."<br/>";
}
echo "</BODY></HTML>";
?>

i already tried system, passthru, exec, popen but, it never creates /tmp/testtt.txt Rights of /tmp:

drwxrwxrwt  10 root root 220K Mai  3 10:28 tmp

What is my mistake?

2 Answers2

0

Try this

exec('sh -c "echo Hallo > /tmp/testtt.txt"', $output, $retval);
0

The Problem was the Sticky bit. /tmp/ has a Sticky bit - so there is a Problem with the PHP exec...

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 05 '22 at 13:02