Create menus and dialogs for shell scripts

Slashdot it! Delicious Share on Facebook Tweet! Digg!
Christopher Hall, Fotolia

Christopher Hall, Fotolia

Greater Comfort

From simple queries to complex menus: Using dialog, you can create a graphical interface for shell scripts with only a few extra lines of code.

The shell by itself is already an application programming interface, but few users still query data from a command line. To adapt to the habits of current users, the dialog tool simulates the elements of a graphical interface.

The look may be a bit old-fashioned but, in terms of speed, the technology is hard to beat. If an X server is running on the system, you can provide users some additional comfort by relying on a dialog counterpart, such as Zenity or Gtkdialog (see the "Relatives" box).

Screens and Menus

To read user input, the built-in Bash read command is often used together with the echo command for simple strings. If you want to change the input prompt, enter the -p option with the new text (Listing 1).

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content