You are viewing jaduks

Previous Entry | Next Entry

"dialog"  utility is superb for developing "small" front-ends.  I was aware of it , but never tried it.  Some days ago I came up with some small applications using it, those looks pretty good(as per my friends views). Here I will discuss about how to program with "dialog" in BASH.
To start with, first lets discuss some of the basic controls available in "dialog", later using them we will develop a simple application.

A copy-paste from man pages of dialog:

Usage: dialog --clear
       dialog --create-rc <file>
       dialog [--title <title>] [--separate-output] [--backtitle <backtitle>] [--clear] <Box options>

Box options:

  --yesno     <text> <height> <width>
  --msgbox    <text> <height> <width>
  --infobox   <text> <height> <width>
  --inputbox  <text> <height> <width> [<init>]
  --textbox   <file> <height> <width>
  --menu      <text> <height> <width> <menu height> <tag1> <item1>...
  --checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...
  --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...
  --guage     <text> <height> <width> <percent>
  --file      <dir>  <height> <width> <mode> [<init>]


CHECKLIST

dialog --checklist "Choose OS:" 10 40 5 \
        1 Linux on \
        2 Solaris off \
        3 "HP UX" off \
        4 AIX off

INPUTBOX

dialog --title "Inputbox - Example" --backtitle "www.jaduks.livejournal.com" \
       --inputbox "Enter your favourite OS here" 8 60


MENU

dialog --title "A dialog Menu Example" \
        --menu "Please choose the command:" 15 55 5 \
        "nestat -r" "Display the kernel routing tables" \
        "netstat -a" "listening / non-listening sockets" \
        "/sbin/ifconfig"  "configure a network interface"



MSGBOX

dialog --title "Example Dialog message box" \
       --msgbox "\n Installation Completed on 172.22.23.124" 6 50

RADIOLIST

dialog --backtitle "Flims" \
  --radiolist "Select Flim:" 10 40 3 \
        1 "Life is beautiful" off \
        2 "Beautiful Mind" on \
        3 "Walk in the clouds" off

Comments

( 1 comment — Leave a comment )
deb_ian
Dec. 5th, 2007 06:07 am (UTC)
Here is a modest way to fully implement dialog
debashish@gaea 26 ~> cat dialog.sh
function dialog_menu {
dialog --title "A dialog Menu Example" --menu "Please choose the\
command:" 15 55 5 "nestat -r" "Display the kernel routing tables" "netstat-a" "listening / non-listening sockets" "/sbin\
/ifconfig" "configure a network interface" Exit "To exit" 2>~/tmp ;

menuitem=`cat ~/tmp`
opt=$?
case $menuitem in
"nestat -r") var=`netstat -r`;
dialog --title "Router Info" --backtitle "Routing Table" --infobox "$var" 10 75;
read;
dialog_menu ;;
"netstat-a") var=`netstat -a`;
dialog --title "Main Menu" --backtitle "Display" --infobox "$var" 100 100;
read;
dialog_menu ;;
"/sbin/ifconfig" ) var=`/sbin/ifconfig`;
dialog --title "Main Menu" --backtitle "Display" --infobox "$var" 100 100;
read;
dialog_menu ;;
Exit) clear;
exit;;
esac
clear
}
dialog_menu
rm ~/tmp

debashish@gaea 28 ~> sh dialog.sh
( 1 comment — Leave a comment )

Profile

jaduks
Jadu Kumar Saikia

Latest Month

January 2008
S M T W T F S
  12345
6789101112
13141516171819
20212223242526
2728293031