如何创建一个php脚本来执行shell命令,将文本写入另一个php文件?
如何创建一个php脚本来执行shell命令,将文本写入另一个php文件?而且没有任何sudo问题。到目前为止,我有这个如何创建一个php脚本来执行shell命令,将文本写入另一个php文件?,php,linux,shell,execute,shell-exec,Php,Linux,Shell,Execute,Shell Exec,如何创建一个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
<?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>";
?>
您的脚本需要在有权限执行所有需要执行的操作的帐户下运行。就这么简单。您的脚本需要在一个帐户下运行,该帐户有权执行您需要执行的所有操作。就这么简单。我不知道你的意思,但是shell_exec(“bash命令要使用”);我只是想知道,为什么要使用shell命令,因为在大多数情况下,fopen()
-fwrite
-fclose
?我不知道你的意思,但是shell_exec(“bash commands to want to use”);我只是想知道,为什么要使用shell命令,因为在大多数情况下,fopen()
-fwrite
-fclose
?同意,还要确保shell\u exec
不是php.ini文件中指定的。与一些共享主机提供商达成一致。此外,还要确保shell_exec
不是php.ini文件中指定的。对于一些共享主机提供商来说,这是一个很好的选择。