Archive

Posts Tagged ‘Bash Programming’

Bash and Shell Dialog Examples

January 26th, 2010 Jimmy No comments

Below are some basic examples of how to create Dialog based Bash scripts for the Linux console. Dialog provides a method of displaying several different types of dialog boxes from shell scripts. The bash dialog example below walks you through a basic “Hello World” shell script using Dialog.

#!/bin/sh
rm /tmp/h.out
while [ 0 ]; do

Create a two option dialog box 11 by 40 characters in size.

dialog --title "Hello World" --menu \
"Select Interface or <Cancel> to exit" \
   11 40 4  \
   "1" "Say Hi!" \
   "2" "Quit" 2>/tmp/h.out

Trap what the user selects into the SEL variable. Values will either be a 1 or a 2 based on our menu above.

SEL="`cat /tmp/h.out`"

Read more…