【发布时间】:2012-05-20 02:01:11
【问题描述】:
我将如何创建一个 php 脚本来执行一个 shell 命令来将文本写入另一个 php 文件?并且没有任何 sudo 问题。到目前为止我有这个。
<?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>";
?>
我使用了 chown wwwdata 和 chmod 777
【问题讨论】:
-
不知道你的意思,但是shell_exec("bash commands to want to use");会做的工作
-
只是想知道,但你为什么要使用 shell 命令,因为在大多数情况下,
fopen()-fwrite-fclose会改为?
标签: php linux shell execute shell-exec