简体   繁体   中英

How would I go about creating a php script to execute a shell command to write text to another php file?

How would I go about creating a php script to execute a shell command to write text to another php file? and not have any sudo problems. I have this so far.

<?php
include("inc/config.php");
$command = "sed -i '$ a\this is line 2 without redirection' admin.php";
$command1 = "cat admin.php";
$output = shell_exec($command);
$output1 = shell_exec($command1);
echo "<pre>$output</pre>";
echo "<pre>$output1</pre>";
?>

and I used chown wwwdata and chmod 777

Your script needs to run under an account that has permissions to do everything you need to do. It's that simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM