I'm not familar with zenity or shell-exec so I may have made a silly mistake...
The following command line works in an Ubuntu terminal window;
PASSWD="$(zenity --password --title=Authentication)"; echo -e $PASSWD | sudo -S nmap -A 192.168.0.1-255;
It puts up a GUI dialogue box to ask for the password and then nmap runs correctly.
If I put the following code in a php file on my local machine, served by Apache:
$network = '192.168.0.1-255';
$cmd = 'PASSWD="$(zenity --password --title=Authentication)"; echo -e $PASSWD | sudo -S nmap -A ' . $network;
echo $cmd;
$output3 = rtrim(shell_exec($cmd));
echo ($output3);
then $cmd is output as
PASSWD="$(zenity --password --title=Authentication)"; echo -e $PASSWD | sudo -S nmap -A 192.168.0.1-255
but nothing else happens.
I looked at run zenity from php and tried giving this command first from a terminal:
xhost local:www-data
but that did not help.
Running, for example, "ls" from shell_exec works fine.
I would welcome any suggestions.