Reputation: 682
I can't find examples related to this problem. I want to enter values to prompt that comes after I send a command
I send this command:
$ssh->exec('sudo pure-pw useradd '.$server_dir.' -u ftpuser -d /home/ftpusers/'.$server_dir);
and it should return a prompt if using putty. It's not the sudo password (i've disabled password prompt for user). The password prompt is for a ftp user.
Password:
after that:
Enter it again:
I was wondering, how could I answer them with phpseclib? I tried:
$ssh-exec('password');
$ssh-exec('password');
but it doesn't work, so I'm kind of stuck now.
edit// I also tried using read and write, but the page keeps on loading forever..
Upvotes: 0
Views: 925
Reputation: 682
Okay so finally I got it working, here's the code:
$ssh->write('sudo pure-pw useradd '.$server_dir.' -u ftpuser -d /home/ftpusers/'.$server_dir."\r\n");
$ssh->read("Password:");
$ssh->write($ftp_pw."\r\n");
$ssh->read("Enter it again:");
$ssh->write($ftp_pw."\r\n");
$ssh->exec("sudo pure-pw mkdb");
Upvotes: 3