You can read more about the build GUI application for bash scripts with Zenity.
How to install Whiptail?
Installing whiptail on Linux is quite simple.
For Ubuntu operating system and Ubuntu base, you use the following command.
$ sudo apt-get install whiptail -y
For CentOS and base CentOS operating systems, use the following command.
$ sudo yum install newt -y
After the installation is complete, you can check the current version of the installed program.
danie@danie-laptop:~/Desktop$ whiptail -v whiptail (newt): 0.52.20
Build the first bash GUI application with Whiptail
Now, we will do a simple example with Whiptail. Copy the contents of the script below onto your computer and name the file, for example,
#!/bin/bash NAME=$(whiptail --inputbox "Type name of the blog:" 8 78 Name --title "WriteBash.com GUI" 3>&1 1>&2 2>&3) exitstatus=$? if [ $exitstatus = 0 ]; then echo "Type name Ok and entered" $NAME echo "Welcome to $NAME" > name_test whiptail --textbox name_test 12 80 else echo "Type name Cancel." fi echo "(Exit status was $exitstatus)"
Next you use the command below to run the script.
$ bash whip.sh
And see what happens. An interface you’ve probably encountered somewhere, right?
There are a lot of setup programs that use the GUI to look like that.
At this point, you will not fully understand how to use whiptail but that’s okay, in the next articles, I will show you how to use it. Using Whiptail will help you be able to build your applications more user friendly. Not always just the command line.If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.
If you appreciate what we share in this blog, you can support us by:
- Stay connected to: Facebook | Twitter | Google Plus | YouTube
- Subscribe email to recieve new posts from us: Sign up now.
- Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
- Become a Supporter - Make a contribution via PayPal.
- Support us by purchasing Ribbon Lite Child theme being using on this website.
We are thankful for your support.