You can’t throw in a GUI for an application that will be run on an enviornment without X. Does that mean you’re left to live with bland command-line prompts for interaction? Think again.
Ever done a text-based install of a Linux distribution? If yes, then I bet you haven’t missed out on those colourful boxes, pitched in combinations of red and blue or yellow and blue, requesting you to type in input and displaying output in return. If you have ever installed Slackware, any of the BSDs, or Debian, I am sure you can’t have overlooked those boxes. What are those? Don’t they look cool? Wouldn’t you want to have one to handle interactions with the enviornment on your command-line application(s)? If you’re anything like me who writes only applications which run from the console, sure as hell you do. I’ve got one word for you: dialog.
Yes! Dialog! Dialog is a program you can find on almost any Linux distribution. It is a program that displays colourful dialog boxes for interaction with the user. It can display information boxes, which contain nothing but text to display on the screen inside a colourful box, menu bars, input boxes, check boxes, etc. You name it, dialog has it.
The manpage documents dialog(1) in detail, being the all-in-one manual to understand how to use dialog and start using it. I see no point in re-hashing the contents of the manpage in my own words. But, yes, I think a simple BASH script to make use of the dialog utility to create a couple of dialogs to take input from user would be sufficient to get the curious onlooker started.
#!/bin/bash dialog --backtitle "Dialog Test Example" --title "Network Settings" --no-shadow --menu "DHCP or Manual" 0 0 0 "dhcp" "Enable DHCP" "manual" "Manual Ip Setting" 2> /tmp/output.file dialog --backtitle "Dialog Test Example" --title "IP Settings" --no-shadow --inputbox "EnterIP:" 0 0 "192.168.1.10" 2> /tmp/output.file # End
Execute the script and be mesmerised by the magic of dialog. By the way, do take a look at the file /tmp/output.file when you’re done running this simple script. ;-)