使用 php 执行命令
Execute command with php
我想知道如何使用 php 形式执行需要输入密码的命令。
我正在使用网站上的表单发送用户名。此示例是我的 php 代码,用于从 Redis 中删除用户,它正在运行。 Rm_user 是用 C++ 编写的可执行文件。
<?php
$email=$_GET['email'];
$command = sprintf("./rm_user %s", $email);
if ($email != null) {
$output = shell_exec($command);
}
echo "$output";
?>
我想知道的是,如何使用 htpasswd
编辑此脚本以将管理员添加到 apache2 服务器。它的命令行是:
sudo htpasswd /etc/apache2/.htpasswd username
如果之后不需要输入密码,那也没什么大不了的。但是在该命令之后,系统会提示您输入密码。那么,是否可以按照我的方式来做,或者我应该考虑其他选择?
你试过了吗sudo htpasswd -b /etc/apache2/.htpasswd username password
?
我想知道如何使用 php 形式执行需要输入密码的命令。
我正在使用网站上的表单发送用户名。此示例是我的 php 代码,用于从 Redis 中删除用户,它正在运行。 Rm_user 是用 C++ 编写的可执行文件。
<?php
$email=$_GET['email'];
$command = sprintf("./rm_user %s", $email);
if ($email != null) {
$output = shell_exec($command);
}
echo "$output";
?>
我想知道的是,如何使用 htpasswd
编辑此脚本以将管理员添加到 apache2 服务器。它的命令行是:
sudo htpasswd /etc/apache2/.htpasswd username
如果之后不需要输入密码,那也没什么大不了的。但是在该命令之后,系统会提示您输入密码。那么,是否可以按照我的方式来做,或者我应该考虑其他选择?
你试过了吗sudo htpasswd -b /etc/apache2/.htpasswd username password
?