2016-06-02 13:29
浏览 87


I want to know how can I execute a command which requires entering password after it, using php form.

I am sending the username using a form on a website. This example is my php code for removing user from Redis and it is working. Rm_user is an executable written in C++.



$command = sprintf("./rm_user %s", $email);

if ($email != null) {
$output = shell_exec($command);
echo "$output";

What is want to know is, how can I edit this script to add admin to the apache2 server, using htpasswd. The command line for it is:

sudo htpasswd /etc/apache2/.htpasswd username

It wouldn't be a big deal if it doesn't require to enter the password afterwards. But after that command you are prompted to enter the password. So, is it possible to do this the way I am doing it, or should I consider other options?

图片转代码服务由CSDN问答提供 功能建议


我使用网站上的表单发送用户名。 这个例子是我的用于从Redis中删除用户的php代码,它正在运行。 Rm_user是用C ++编写的可执行文件。

 $ email = $ _ GET ['email'];  
 $ command = sprintf(“./ rm_user%s”,$ email); 
if($ email!= null){
 $ output = shell_exec($ command); 
echo“  $ output“; 

我想知道的是,如何使用 htpasswd的。 它的命令行是:

  sudo htpasswd /etc/apache2/.htpasswd username 

它不会 如果之后不需要输入密码,那将是一件大事。 但在该命令之后,系统会提示您输入密码。 那么,我可以按照我的方式做到这一点,还是应该考虑其他选择?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douxi3554 2016-06-06 23:26

    Have you tried sudo htpasswd -b /etc/apache2/.htpasswd username password?

    解决 无用
    打赏 举报

相关推荐 更多相似问题