Well no matter how advanced programming gets sometimes you just need to get back to something simple as dirt. For instance you need a quick interface just to provide a menu. You could approach this in many different ways, but how much simpler could it be than creating a dialog with a shell script?
Lets say for instance on my web server I have a list of scripts I commonly run. Normally I would have to do an “ls” because I can never remember those file names, and I can never remember the arguments that go with them. You can whip up a dialog within a matter of 5 minutes that can be run at the terminal and look like the following:
Ok, I know this is nothing new(ancient if anything), nor rocket science, but sometimes getting back to the basics for something quick is extremely helpful. This simple code would look like the following:
#!/bin/sh tempfile=`tempfile` dialog --title "Run a useful script" \ --menu "Choose a script:" 15 55 5 \ "script1" "Script 1 (foo)" \ "script2" "Script 2 (bar)" \ "script3" "Script 3 (useless)" 2> $tempfile return_value=$? you_chose=`cat $tempfile` case $return_value in 0) echo "'$you_chose' would now be run";; esac
apot - Jan 27, 2009