Taking password using GUI in linux script using whiptail

In the post we saw how to install and use whiptail. We can use whiptail to accept passwords from user too.

The syntax to use the password is


The password entered will not be visible and will appear only as *. But by default the entered password is sent to the error console.

 photo whip_pass.png

To use the password in the script, we will have to swap the standard error and standard output consoles which can be done as below.

what ever password the user enters, it will be stored in the variable input.

Here is an example script, in which we will take the user password and verify if the same is correct or not.

Save the script, give it execute permission and run it. $ chmod 777 $ ./

 photo whip_pass.png

 photo whip_correct_pass.png

Follow by Email