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++.
<?php
$email=$_GET['email'];
$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?
Have you tried sudo htpasswd -b /etc/apache2/.htpasswd username password
?