我想用whiptail密码询问你的sudo密码,然后用它来运行sudo script.sh这可能吗?
我已经用whiptail输入密码尝试了这个sudo命令
sudo -S <<< $psw script.sh
echo $ psw | sudo -S
完整代码
#!/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