I want to ask your sudo password with whiptail password and then use it to run sudo script.sh this is possible?
I have tried this sudo command with the whiptail input for password
sudo -S <<< $psw script.sh
echo $ psw | sudo -S
Full Code
#!/bin/bash
#Password Input
psw=$(whiptail --title "Test Password Box" --passwordbox "Enter your password and choose Ok to continue." 10 60 3>&1 1>&2 2>&3)
#Password If
exitstatus=$?
if [ $exitstatus = 0 ]; then
sudo -S <<< $psw script.sh
else
#Password If cancel
whiptail --title "Cancel" --msgbox "Operation Cancel" 10 60
fi
A quick check shows the script should work (works for me). Your script is calling sudo
separately from whiptail
, so the two are not interfering with each other's use of the terminal.
The script should begin with
#!/bin/bash
because it uses the here-string
<<< $psw