Automatically input a response (bash/php)

31 Views Asked by At

I put up a Jitsi Server. I just created a web interface for user management based on prosody. So, I want to change a user password via HTML form.

So I created the following PHP code:

<?php

if(isset($_POST['reset'])) {
$username=$_POST['resetname'];
$password=$_POST['resetpw'];
$password2=$_POST['resetpw2'];

if($password == $password2){
$param1= escapeshellarg($username);
$param2= escapeshellarg($password);
$param3= escapeshellarg($password2);

$reset = system("echo prosodyctl passwd $param1@$Website '<<!'\n $param2\n $param3\n ! >> /var/www/content/exe/reset.sh");
[...]

The prosodyctl command need su rights, so I pipe this command + input in a new file and execute this script with cron after a few minutes. But when I wrote \n in the commandline, it went blank.

Prosody syntax for this command:

prosodyctl passwd user@host
(Asking for a new password)
(Retype new password)

Do you know why it won't work with \n in PHP? Did I make a mistake somewhere?

Thanks

0

There are 0 best solutions below