dslinux/user/dialog/samples README calendar calendar-stdout calendar2 calendar2-stdout calendar3 calendar3-stdout checklist checklist-8bit checklist-utf8 checklist1 checklist10 checklist2 checklist3 checklist4 checklist5 checklist6 checklist7 checklist8 checklist9 checklist9.txt copismall debian.rc dialog.py form1 form1-both form1-extra form1-help form2 form3 form4 form5 form6 fselect fselect-stdout fselect1 fselect1-stdout fselect2 fselect2-stdout gauge gauge0 gauge0-input-fd gauge2 gauge3 infobox infobox1 infobox2 infobox3 infobox4 infobox5 infobox6 inputbox inputbox-both inputbox-extra inputbox-help inputbox1 inputbox2 inputbox3 inputbox4 inputbox5 inputbox6-8bit inputbox6-utf8 inputbox7 inputmenu inputmenu-stdout inputmenu1 inputmenu2 inputmenu3 inputmenu4 killall listing menubox menubox-8bit menubox-utf8 menubox1 menubox10 menubox2 menubox3 menubox4 menubox5 menubox6 menubox7 menubox8 menubox9 msgbox msgbox-help msgbox1 msgbox2 msgbox3 msgbox4-8bit msgbox4-eucj! p msgbox4-utf8 msgbox5 msgbox6 msgbox6a password password1 password2 passwordform1 pause pause-help progress progress2 radiolist radiolist10 radiolist2 radiolist3 radiolist4 rotated-data slackware.rc sourcemage.rc tailbox tailboxbg tailboxbg1 tailboxbg2 testdata-8bit textbox textbox.txt textbox2 textbox3 timebox timebox-stdout timebox2 timebox2-stdout wheel whiptail.rc yesno yesno-both yesno-extra yesno-help yesno2 yesno3

stsp stsp at user.in-berlin.de
Mon Oct 23 22:59:35 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/dialog/samples
In directory antilope:/tmp/cvs-serv17426/samples

Added Files:
	README calendar calendar-stdout calendar2 calendar2-stdout 
	calendar3 calendar3-stdout checklist checklist-8bit 
	checklist-utf8 checklist1 checklist10 checklist2 checklist3 
	checklist4 checklist5 checklist6 checklist7 checklist8 
	checklist9 checklist9.txt copismall debian.rc dialog.py form1 
	form1-both form1-extra form1-help form2 form3 form4 form5 
	form6 fselect fselect-stdout fselect1 fselect1-stdout fselect2 
	fselect2-stdout gauge gauge0 gauge0-input-fd gauge2 gauge3 
	infobox infobox1 infobox2 infobox3 infobox4 infobox5 infobox6 
	inputbox inputbox-both inputbox-extra inputbox-help inputbox1 
	inputbox2 inputbox3 inputbox4 inputbox5 inputbox6-8bit 
	inputbox6-utf8 inputbox7 inputmenu inputmenu-stdout inputmenu1 
	inputmenu2 inputmenu3 inputmenu4 killall listing menubox 
	menubox-8bit menubox-utf8 menubox1 menubox10 menubox2 menubox3 
	menubox4 menubox5 menubox6 menubox7 menubox8 menubox9 msgbox 
	msgbox-help msgbox1 msgbox2 msgbox3 msgbox4-8bit msgbox4-eucjp 
	msgbox4-utf8 msgbox5 msgbox6 msgbox6a password password1 
	password2 passwordform1 pause pause-help progress progress2 
	radiolist radiolist10 radiolist2 radiolist3 radiolist4 
	rotated-data slackware.rc sourcemage.rc tailbox tailboxbg 
	tailboxbg1 tailboxbg2 testdata-8bit textbox textbox.txt 
	textbox2 textbox3 timebox timebox-stdout timebox2 
	timebox2-stdout wheel whiptail.rc yesno yesno-both yesno-extra 
	yesno-help yesno2 yesno3 
Log Message:
Adding pristine copy of dialog-1.0-20060221 so I can branch from it.


--- NEW FILE: textbox.txt ---
Hi, this is a text dialog box. It can be used to display text from a file.
The file should not contain any 'tab' characters, so you should 'expand'
the file first if it contains 'tab' characters.

It's like a simple text file viewer, with these keys implemented:

PGDN/SPACE     - Move down one page
PGUP/'b'       - Move up one page
ENTER/DOWN/'j' - Move down one line
UP/'k'         - Move up one line
LEFT/'h'       - Scroll left
RIGHT/'l'      - Scroll right
'0'            - Move to beginning of line
HOME/'g'       - Move to beginning of file
END/'G'        - Move to end of file
'/'            - Forward search
'?'            - Backward search
'n'            - Repeat last search (forward)
'N'            - Repeat last search (backward)


The following is a sample text file:



--- NEW FILE: yesno-extra ---
#!/bin/sh
# $Id: yesno-extra,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "YES/NO/MAYBE BOX" \
	--clear \
	--ok-label "Next" \
	--no-label "Cancel" \
	--extra-label "Previous" --extra-button \
        --yesno "Hi, this is a yes/no dialog box with its labels changed. \
                 You can use this to ask \
                 questions that have an answer of either yes or no (or maybe). \
                 BTW, do you notice that long lines will be automatically \
                 wrapped around so that they can fit in the box? You can \
                 also control line breaking explicitly by inserting \
                 'backslash n' at any place you like, but in this case, \
                 auto wrap around will be disabled and you will have to \
                 control line breaking yourself." 15 61

case $? in
  0)
    echo "Next chosen.";;
  1)
    echo "Cancel chosen.";;
  2)
    echo "Help pressed.";;
  3)
    echo "Previous pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: inputbox5 ---
#!/bin/sh
# $Id: inputbox5,v 1.1 2006-10-23 20:59:31 stsp Exp $
# use --output-fd to write to a different output than stderr
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear --output-fd 4 \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 4> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: calendar3 ---
#!/bin/sh
# $Id: calendar3,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
USERDATE=`$DIALOG --extra-button --extra-label "Hold" --help-button --title "CALENDAR" --calendar "Please choose a date..." 0 0 7 7 1981 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "Help pressed.";;
  3)
    echo "Hold pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: calendar2 ---
#!/bin/sh
# $Id: calendar2,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
USERDATE=`$DIALOG --title "CALENDAR" --calendar "Please choose a date..." 0 0 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: fselect2-stdout ---
#!/bin/sh
# $Id: fselect2-stdout,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

FILE=`$DIALOG --stdout --title "Please choose a file" --fselect $HOME/ 0 0`

case $? in
	0)
		echo "\"$FILE\" chosen";;
	1)
		echo "Cancel pressed.";;
	255)
		echo "Box closed.";;
esac

--- NEW FILE: infobox5 ---
#! /bin/sh
# $Id: infobox5,v 1.1 2006-10-23 20:59:30 stsp Exp $
# get rid of all flickering by constructing a script unroll the loop, leaving
# us in curses-mode until we're done counting.
: ${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

left=10
unit="seconds"
last='\'

cat >>$tempfile <<EOF
$DIALOG $last
EOF

while test $left != 0
do

cat >>$tempfile <<EOF
	--sleep 1 \
	--begin 0 5 \
	--title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 0 0 $last
EOF

left=`expr $left - 1`
test $left = 1 && unit="second"
done

echo >>$tempfile

. $tempfile

--- NEW FILE: menubox2 ---
#!/bin/sh
# $Id: menubox2,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --default-item "MSDOS" --clear --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" 2> $tempfile

retval=$?

case $retval in
  0)
    echo "`cat $tempfile` chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: menubox3 ---
#!/bin/sh
# $Id: menubox3,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --item-help --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486"    "Why use Linux?" \
        "NetBSD" "Another free Unix Clone for 386/486" "Or NetBSD?" \
        "OS/2"   "IBM OS/2"                            "aka \"Warp\"" \
        "WIN NT" "Microsoft Windows NT"                "hmm" \
        "PCDOS"  "IBM PC DOS"                          "clone of a clone" \
        "MSDOS"  "Microsoft DOS"                       "DOS: Disk Operating System, originally for an IBM contract, hence using the same jargon" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox4 ---
#!/bin/sh
# $Id: menubox4,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --item-help --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"    "Why use Linux?" \
        "NetBSD" "Another free Unix Clone for 386/486 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Or NetBSD?" \
        "OS/2"   "IBM OS/2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            "aka \"Warp\"" \
        "WIN NT" "Microsoft Windows NT xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                "hmm" \
        "PCDOS"  "IBM PC DOS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          "clone of a clone" \
        "MSDOS"  "Microsoft DOS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                       "DOS: Disk Operating System, originally for an IBM contract, hence using the same jargon" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox5 ---
#!/bin/sh
# $Id: menubox5,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --help-button --item-help --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"    "Why use Linux?" \
        "NetBSD" "Another free Unix Clone for 386/486 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" "Or NetBSD?" \
        "OS/2"   "IBM OS/2 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            "aka \"Warp\"" \
        "WIN NT" "Microsoft Windows NT xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                "hmm" \
        "WIN 2K" "Microsoft Windows 2000 xxxxxxxxxxxxxxxxxxxxxxxxxxxx"                "hmm" \
        "WIN XP" "Microsoft Windows XP (son of Windows 95) xxxxxxxxxx"                "hmm" \
        "WIN 95" "Microsoft Windows 95 (son of MSDOS) xxxxxxxxxxxxxxx"                "hmm" \
        "PCDOS"  "IBM PC DOS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          "clone of a clone" \
        "MSDOS"  "Microsoft DOS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                       "DOS: Disk Operating System, originally for an IBM contract, hence using the same jargon" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox6 ---
#!/bin/sh
# $Id: menubox6,v 1.1 2006-10-23 20:59:31 stsp Exp $
# example showing the --colors option
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --item-help --title "MENU BOX" --colors \
        --menu "Hi, this is a \Zumenu\Zn box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the \Z4UP/DOWN\Zn arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
\Z2number\Zn keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for \Zu386/486"    "Why use \ZbLinux?" \
        "NetBSD" "Another free Unix Clone for \Zu386/486" "Or \ZbNetBSD?" \
        "OS/2"   "IBM OS/2"                            "aka \"Warp\"" \
        "WIN NT" "Microsoft Windows NT"                "hmm" \
        "PCDOS"  "IBM PC \ZrDOS"                          "clone of a clone" \
        "MSDOS"  "Microsoft \ZrDOS"                       "\ZbDOS\Zn: \Zb\Z3D\Znisk \Zb\Z3O\Znperating \Zb\Z3S\Znystem, originally for an IBM contract, hence using the same jargon" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox7 ---
#!/bin/sh
# $Id: menubox7,v 1.1 2006-10-23 20:59:31 stsp Exp $
# example with --extra-button
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --item-help --extra-button --extra-label "Choice" \
	--title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486"    "Why use Linux?" \
        "NetBSD" "Another free Unix Clone for 386/486" "Or NetBSD?" \
        "OS/2"   "IBM OS/2"                            "aka \"Warp\"" \
        "WIN NT" "Microsoft Windows NT"                "hmm" \
        "PCDOS"  "IBM PC DOS"                          "clone of a clone" \
        "MSDOS"  "Microsoft DOS"                       "DOS: Disk Operating System, originally for an IBM contract, hence using the same jargon" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  3)
    echo "Extra (Choice) chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox8 ---
#!/bin/sh
# $Id: menubox8,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
value=`$DIALOG --help-button \
	--default-item "MSDOS" \
	--clear \
	--title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" \
2>&1 1>&3`
retval=$?
exec 3>&-

case $retval in
  0)
    echo "$value chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "Help pressed ($value)";;
  255)
    if test -n "$value" ; then
      echo "$value"
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: menubox9 ---
#!/bin/sh
# $Id: menubox9,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
value=`$DIALOG --help-button \
	--clear \
	--title "Select Linux installation partition:" \
	--menu \
"Please select a partition from the following list to use for your \
root (/) Linux partition." 13 70 5 \
"/dev/hda2" "Linux native 30724312K" \
"/dev/hda4" "Linux native 506047K" \
"/dev/hdb1" "Linux native 4096543K" \
"/dev/hdb2" "Linux native 2586465K" \
"---" "(add none, continue with setup)" \
"---" "(add none, continue with setup)" \
"---" "(add none, continue with setup)" \
"---" "(add none, continue with setup)" \
"---" "(add none, continue with setup)" \
2>&1 1>&3`
retval=$?
exec 3>&-

case $retval in
  0)
    echo "$value chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "Help pressed ($value)";;
  255)
    if test -n "$value" ; then
      echo "$value"
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: msgbox3 ---
#!/bin/sh
# $Id: msgbox3,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

width=35
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --clear --no-collapse \
        --msgbox "\
	H   H EEEEE L     L      OOO
	H   H E     L     L     O   O
	HHHHH EEEEE L     L     O   O
	H   H E     L     L     O   O
	H   H EEEEE LLLLL LLLLL  OOO

Hi, this is a simple message box.  You can use this to \
display any message you like.  The box will remain until \
you press the ENTER key." 15 $width
test $? = 255 && break
width=`expr $width + 1`
done

--- NEW FILE: msgbox2 ---
#!/bin/sh
# $Id: msgbox2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "MESSAGE BOX" --trim \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with dialogs default aspect ratio of 9." 0 0
test $? = 255 && exit

$DIALOG --aspect 12 --title "MESSAGE BOX  aspect=12" --trim \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with an aspect ratio of 12." 0 0
test $? = 255 && exit

$DIALOG --aspect 6 --title "MESSAGE BOX  aspect=6" --trim \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with an aspect ratio of 6." 0 0
test $? = 255 && exit

$DIALOG --aspect 6 --cr-wrap --title "MESSAGE BOX aspect=6 with --cr-wrap" \
        --trim --msgbox "\
           Hi, this is a simple
           message box. You can
          use this to display any 
             message you like.
The box will remain until you press the ENTER key.  This box is being displayed with an aspect ratio of 6, and using --cr-wrap.\n" 0 0
test $? = 255 && exit

--- NEW FILE: msgbox5 ---
#!/bin/sh
# $Id: msgbox5,v 1.1 2006-10-23 20:59:32 stsp Exp $
# this differs from msgbox3 by making a window small enough to force scrolling.
: ${DIALOG=dialog}

width=35
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --clear --no-collapse \
        --msgbox "\
	H   H EEEEE L     L      OOO
	H   H E     L     L     O   O
	HHHHH EEEEE L     L     O   O
	H   H E     L     L     O   O
	H   H EEEEE LLLLL LLLLL  OOO

Hi, this is a simple message box.  You can use this to \
display any message you like.  The box will remain until \
you press the ENTER key." 10 $width
test $? = 255 && break
width=`expr $width + 1`
done

--- NEW FILE: msgbox6 ---
#!/bin/sh
# $Id: msgbox6,v 1.1 2006-10-23 20:59:32 stsp Exp $
# this differs from msgbox3 by making a window small enough to force scrolling.
: ${DIALOG=dialog}

width=35
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --clear \
        --msgbox "\
	a b c d e f g h j i j k l m n o p q r s t u v w x y z
	A B C D E F G H J I J K L M N O P Q R S T U V W X Y Z
" 10 $width
test $? = 255 && break
width=`expr $width + 1`
done

--- NEW FILE: whiptail.rc ---
# $Id: whiptail.rc,v 1.1 2006-10-23 20:59:33 stsp Exp $
# Run-time configuration file for dialog, matches whiptail's color scheme.

# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 0

# Make tab-traversal for checklist, etc., include the list.
visit_items = ON

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (YELLOW,BLUE,ON)

# Shadow color
shadow_color = (BLACK,BLACK,ON)

# Dialog box color
dialog_color = (BLACK,WHITE,OFF)

# Dialog box title color
title_color = (RED,WHITE,ON)

# Dialog box border color
border_color = (WHITE,WHITE,ON)

# Active button color
button_active_color = (WHITE,RED,ON)

# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)

# Active button key color
button_key_active_color = (WHITE,RED,ON)

# Inactive button key color
button_key_inactive_color = (BLACK,WHITE,OFF)

# Active button label color
button_label_active_color = (WHITE,RED,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)

# Input box color
inputbox_color = (BLACK,WHITE,OFF)

# Input box border color
inputbox_border_color = (BLACK,WHITE,OFF)

# Search box color
searchbox_color = (BLACK,WHITE,OFF)

# Search box title color
searchbox_title_color = (RED,WHITE,ON)

# Search box border color
searchbox_border_color = (WHITE,WHITE,ON)

# File position indicator color
position_indicator_color = (RED,WHITE,ON)

# Menu box color
menubox_color = (YELLOW,BLUE,OFF)

# Menu box border color
menubox_border_color = (YELLOW,BLUE,ON)

# Item color
item_color = (YELLOW,BLUE,OFF)

# Selected item color
item_selected_color = (YELLOW,BLUE,ON)

# Tag color
tag_color = (YELLOW,BLUE,ON)

# Selected tag color
tag_selected_color = (YELLOW,BLUE,ON)

# Tag key color
tag_key_color = (YELLOW,BLUE,OFF)

# Selected tag key color
tag_key_selected_color = (WHITE,BLUE,ON)

# Check box color
check_color = (YELLOW,BLUE,OFF)

# Selected check box color
check_selected_color = (YELLOW,BLUE,ON)

# Up arrow color
uarrow_color = (YELLOW,BLUE,ON)

# Down arrow color
darrow_color = (YELLOW,BLUE,ON)

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = (WHITE,BLUE,ON)

# Form text color
form_text_color = (WHITE,CYAN,ON)

--- NEW FILE: msgbox6a ---
#!/bin/sh
# $Id: msgbox6a,v 1.1 2006-10-23 20:59:32 stsp Exp $
# this differs from msgbox3 by making a window small enough to force scrolling.
: ${DIALOG=dialog}

width=35
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --clear \
        --msgbox "\
	.a .b .c .d .e .f .g .h .j .i .j .k .l .m .n .o .p .q .r .s .t .u .v .w .x .y .z
	.A .B .C .D .E .F .G .H .J .I .J .K .L .M .N .O .P .Q .R .S .T .U .V .W .X .Y .Z
" 10 $width
test $? = 255 && break
width=`expr $width + 1`
done

--- NEW FILE: infobox6 ---
#! /bin/sh
# $Id: infobox6,v 1.1 2006-10-23 20:59:30 stsp Exp $
# get rid of all flickering by constructing a script unroll the loop, leaving
# us in curses-mode until we're done counting.
#
# a little fancier than infobox5, this moves the widget at each step.
: ${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

left=10
unit="seconds"
last='\'

cat >>$tempfile <<EOF
$DIALOG $last
EOF

while test $left != 0
do

cat >>$tempfile <<EOF
	--sleep 1 \
	--begin $left `expr $left + 5` \
	--title "INFO BOX" $last
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 0 0 $last
EOF

left=`expr $left - 1`
test $left = 1 && unit="second"
done

echo >>$tempfile

. $tempfile

--- NEW FILE: checklist-8bit ---
#! /bin/sh
# $Id: checklist-8bit,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

. ./testdata-8bit

$DIALOG --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "`./rotated-data 0 $SAMPLE`"  "It's an `./rotated-data 0 $SAMPLE`." off \
        "`./rotated-data 1 $SAMPLE`"    "No, that's not my `./rotated-data 1 $SAMPLE`." ON \
        "`./rotated-data 2 $SAMPLE`" "Yeah, that's `./rotated-data 2 $SAMPLE`." off \
        "`./rotated-data 3 $SAMPLE`"    "Normally not a `./rotated-data 3 $SAMPLE`." off \
        "`./rotated-data 4 $SAMPLE`"    "No, never put a `./rotated-data 4 $SAMPLE` there!" oN \
        "`./rotated-data 5 $SAMPLE`"   "Cats like `./rotated-data 5 $SAMPLE`." On \
        "`./rotated-data 6 $SAMPLE`"  "You `./rotated-data 6 $SAMPLE` how it is." on 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  $DIALOG_OK)
    echo "'$choice' chosen.";;
  $DIALOG_CANCEL)
    echo "Cancel pressed.";;
  $DIALOG_ESC)
    echo "ESC pressed.";;
  *)
    echo "Unexpected return code: $retval (ok would be $DIALOG_OK)";;
esac

--- NEW FILE: form3 ---
#! /bin/sh
# $Id: form3,v 1.1 2006-10-23 20:59:30 stsp Exp $
# form1 with --help-button
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --help-button \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Help data:\n\
$show" 10 40
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: form1-both ---
#! /bin/sh
# $Id: form1-both,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --extra-button --help-button \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		echo "Button 2 (Help) pressed."
		exit
		;;
	3)
		echo "Button 3 (Extra) pressed."
		exit
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: tailbox ---
#!/bin/sh
# $Id: tailbox,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

./killall listing
./listing >listing.out &

$DIALOG --title "TAIL BOX" \
        --tailbox listing.out 24 70

case $? in
  0)
    echo "OK";;
  255)
    echo "ESC pressed.";;
esac

./killall listing

--- NEW FILE: checklist ---
#! /bin/sh
# $Id: checklist,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"  "It's an apple." off \
        "Dog"    "No, that's not my dog." ON \
        "Orange" "Yeah, that's juicy." off \
        "Chicken"    "Normally not a pet." off \
        "Cat"    "No, never put a dog and a cat together!" oN \
        "Fish"   "Cats like fish." On \
        "Lemon"  "You know how it tastes." on 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  $DIALOG_OK)
    echo "'$choice' chosen.";;
  $DIALOG_CANCEL)
    echo "Cancel pressed.";;
  $DIALOG_ESC)
    echo "ESC pressed.";;
  *)
    echo "Unexpected return code: $retval (ok would be $DIALOG_OK)";;
esac

--- NEW FILE: radiolist ---
#! /bin/sh
# $Id: radiolist,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --backtitle "No Such Organization" \
	--title "RADIOLIST BOX" --clear \
        --radiolist "Hi, this is a radiolist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"  "It's an apple." off \
        "Dog"    "No, that's not my dog." ON \
        "Orange" "Yeah, that's juicy." off \
        "Chicken"    "Normally not a pet." off \
        "Cat"    "No, never put a dog and a cat together!" off \
        "Fish"   "Cats like fish." off \
        "Lemon"  "You know how it tastes." off 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: msgbox4-eucjp ---
#!/bin/sh
# $Id: msgbox4-eucjp,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

width=35
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --clear --no-collapse \
        --msgbox "\
This sample is written in EUC-JP.
There are several checking points:
(1) whether the fullwidth characters are displayed well or not,
(2) whether the width of characters are evaluated properly, and
(3) whether the character at line-folding is lost or not.

¤¢¤¤¤¦¤¨¤ª¤«¤­¤¯¤±¤³¤µ¤·¤¹¤»¤½¤¿¤Á¤Ä¤Æ¤È¤Ê¤Ë¤Ì¤Í¤Î
£±£²£³£´£µ£¶£·£¸£¹£°£±£²£³£´£µ£¶£·£¸£¹£°£±£²£³£´£µ
£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù

Hi, this is a simple message box.  You can use this to \
display any message you like.  The box will remain until \
you press the ENTER key." 22 $width
width=`expr $width + 1`
done

--- NEW FILE: radiolist10 ---
#! /bin/sh
# $Id: radiolist10,v 1.1 2006-10-23 20:59:32 stsp Exp $
# zero-width column
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG \
	--backtitle "No such organization" \
	--title "RADIOLIST BOX" \
        --radiolist "Hi, this is a radiolist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
	Dialog		"" on \
	Readline	"" off \
	Gnome		"" off \
	Kde		"" off \
	Editor		"" off \
	Noninteractive	"" on \
        2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: checklist-utf8 ---
#! /bin/sh
# $Id: checklist-utf8,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

case none"$LANG$LC_ALL$LC_CTYPE" in
*UTF-8*)
	;;
*)
	echo "This script must be run in a UTF-8 locale"
	exit 1
	;;
esac

$DIALOG --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "APPLE"  "It's an APPLE." off \
        "DOG"    "No, that's not my DOG." ON \
        "ORANGE" "Yeah, that's JUICY." off \
        "CHICKEN"    "Normally not a PET." off \
        "CAT"    "No, never put a DOG and a CAT together!" oN \
        "FISH"   "Cats like FISH." On \
        "LEMON"  "You KNOW how it TASTES." on 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  $DIALOG_OK)
    echo "'$choice' chosen.";;
  $DIALOG_CANCEL)
    echo "Cancel pressed.";;
  $DIALOG_ESC)
    echo "ESC pressed.";;
  *)
    echo "Unexpected return code: $retval (ok would be $DIALOG_OK)";;
esac

--- NEW FILE: listing ---
#!/bin/sh
while true
do
date
ls -lrt
sleep 1
done

--- NEW FILE: README ---
You can set the environment-variable DIALOG to whatever program you
want to check. Default is "dialog".

Use "export DIALOG=/usr/bin/dialog" for sh or "setenv DIALOG ../dialog" for csh
to test the /usr/bin/dialog program.

--

There is no documentation at the moment for cdialog 0.9a, but here are a 
small installer (copismall) for 'points' fido-like, that uses cdialog 0.9a.
It can demonstrate some of the new features... run "copismall" paying 
attention because after asking for some things, it then installs and/or
configures programs like as Inn, Ifmail, Smail to make the 'point'. 
It's in Italian language only at moment, but the code is bash......
If you want look at other much professional products FREE realized with 
cdialog and that use much of the other new characteristics, look for one of
the ComeOn Point Suites v1.1+. Makers are a sub-group of the ComeOn Linux
Development Team... ComeOn Linux! follows GNU philosophy.

Mail demarco_p at abramo.it to have the actual location of these Suites and 
of other free ComeOn Linux! software, or if you want more info about 
ComeOn Linux!

To run the "ComeOn Point Installer! v0.9a.small", type:
$ copismall

Other external samples could be:

copa  - ComeOn Point Administrator! v0.8
copm  - ComeOn Point Maintainer! v0.2
copi  - ComeOn Point Installer! v0.9 (system-wide version of copi)
coepi - ComeOn Expert Point Installer! v1.3 (Professional)

cops  - ComeOn Point Suite! v1.1
copsp - ComeOn Point Suite Professional! v1.1

coui  - ComeOn UUCP Installer! v0.1 (makes dialup networks in a moment)


--- NEW FILE: msgbox ---
#!/bin/sh
# $Id: msgbox,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "MESSAGE BOX" --clear \
        --msgbox "Hi, this is a simple message box. You can use this to \
                  display any message you like. The box will remain until \
                  you press the ENTER key." 10 41

case $? in
  0)
    echo "OK";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: passwordform1 ---
#! /bin/sh
# $Id: passwordform1,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --backtitle "$backtitle" \
	  --insecure \
	  --passwordform "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		echo "Button 2 (Help) pressed."
		exit
		;;
	3)
		echo "Button 3 (Extra) pressed."
		exit
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: msgbox-help ---
#!/bin/sh
# $Id: msgbox-help,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "MESSAGE BOX" --clear \
	--help-button \
        --msgbox "Hi, this is a simple message box. You can use this to \
                  display any message you like. The box will remain until \
                  you press the ENTER key." 10 41

case $? in
  0)
    echo "OK";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: gauge0 ---
#!/bin/sh
# $Id: gauge0,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

PCT=10
(
sleep 1
while test $PCT != 110
do
echo "XXX"
echo $PCT
echo "The new\n\
message ($PCT percent)"
echo "XXX"
PCT=`expr $PCT + 10`
sleep 1
done
) |

$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 0 0 0

--- NEW FILE: yesno-help ---
#!/bin/sh
# $Id: yesno-help,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "YES/NO BOX" --clear --help-button \
        --yesno "Hi, this is a yes/no dialog box. You can use this to ask \
                 questions that have an answer of either yes or no. \
                 BTW, do you notice that long lines will be automatically \
                 wrapped around so that they can fit in the box? You can \
                 also control line breaking explicitly by inserting \
                 'backslash n' at any place you like, but in this case, \
                 auto wrap around will be disabled and you will have to \
                 control line breaking yourself." 15 61

case $? in
  0)
    echo "Yes chosen.";;
  1)
    echo "No chosen.";;
  2)
    echo "Help pressed.";;
  3)
    echo "Extra pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: gauge2 ---
#!/bin/sh
# $Id: gauge2,v 1.1 2006-10-23 20:59:30 stsp Exp $
# The original dialog program assumed the first line after the first "XXX"
# was a percentage value (compare with "gauge" script).
: ${DIALOG=dialog}

(echo "10" ; sleep 2 ; 

echo "XXX"; 
echo "The new"
echo "\\n"
echo "message";
echo "XXX";
echo "20"
sleep 2; 

echo "75" ; sleep 1
echo "100") | \

$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 10 40 0

if [ "$?" = 255 ] ; then
	echo ""
	echo "Box closed !"
fi

--- NEW FILE: menubox-8bit ---
#!/bin/sh
# $Id: menubox-8bit,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

. ./testdata-8bit

$DIALOG --clear --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "`./rotated-data 0 $SAMPLE`"  "The Great Unix Clone for 386/486" \
        "`./rotated-data 1 $SAMPLE`" "Another free Unix Clone for 386/486" \
        "`./rotated-data 2 $SAMPLE`" "IBM OS/2" \
        "`./rotated-data 3 $SAMPLE`" "Microsoft Windows NT" \
        "`./rotated-data 4 $SAMPLE`" "IBM PC DOS" \
        "`./rotated-data 5 $SAMPLE`" "Microsoft DOS" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: slackware.rc ---
# $Id: slackware.rc,v 1.1 2006-10-23 20:59:32 stsp Exp $
# Run-time configuration file for dialog, matches Slackware color scheme.
#
# Types of values:
#
# Number     -  <number>
# String     -  "string"
# Boolean    -  <ON|OFF>
# Attribute  -  (foreground,background,highlight?)

# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 0

# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (WHITE,BLUE,OFF)

# Shadow color
shadow_color = (WHITE,BLACK,OFF)

# Dialog box color
dialog_color = (BLACK,CYAN,OFF)

# Dialog box title color
title_color = (YELLOW,CYAN,ON)

# Dialog box border color
border_color = (CYAN,CYAN,ON)

# Active button color
button_active_color = (WHITE,BLUE,ON)

# Inactive button color
button_inactive_color = (BLACK,CYAN,OFF)

# Active button key color
button_key_active_color = (WHITE,BLUE,ON)

# Inactive button key color
button_key_inactive_color = (RED,CYAN,OFF)

# Active button label color
button_label_active_color = (WHITE,BLUE,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,CYAN,ON)

# Input box color
inputbox_color = (BLUE,WHITE,OFF)

# Input box border color
inputbox_border_color = (CYAN,CYAN,ON)

# Search box color
searchbox_color = (YELLOW,WHITE,ON)

# Search box title color
# FIXME
searchbox_title_color = (WHITE,WHITE,ON)

# Search box border color
searchbox_border_color = (RED,WHITE,OFF)

# File position indicator color
position_indicator_color = (RED,CYAN,OFF)

# Menu box color
menubox_color = (BLACK,CYAN,OFF)

# Menu box border color
menubox_border_color = (CYAN,CYAN,ON)

# Item color
item_color = (BLACK,CYAN,OFF)

# Selected item color
item_selected_color = (WHITE,BLUE,OFF)

# Tag color
tag_color = (YELLOW,CYAN,ON)

# Selected tag color
tag_selected_color = (WHITE,BLUE,OFF)

# Tag key color
tag_key_color = (RED,CYAN,OFF)

# Selected tag key color
tag_key_selected_color = (RED,BLUE,ON)

# Check box color
check_color = (BLACK,CYAN,OFF)

# Selected check box color
check_selected_color = (WHITE,CYAN,ON)

# Up arrow color
uarrow_color = (GREEN,CYAN,ON)

# Down arrow color
darrow_color = (GREEN,CYAN,ON)

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = (BLUE,WHITE,OFF)

# Form text color
form_text_color = (CYAN,BLUE,ON)

--- NEW FILE: inputbox-both ---
#!/bin/sh
# $Id: inputbox-both,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
	--extra-button \
	--help-button \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: infobox4 ---
#! /bin/sh
# $Id: infobox4,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

left=10
unit="seconds"
while test $left != 0
do

$DIALOG --sleep 1 \
	--begin 0 5 \
	--title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 0 0
left=`expr $left - 1`
test $left = 1 && unit="second"
done

--- NEW FILE: calendar3-stdout ---
#!/bin/sh
# $Id: calendar3-stdout,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

USERDATE=`$DIALOG --extra-button --extra-label "Hold" --help-button --stdout --title "CALENDAR" --calendar "Please choose a date..." 0 0 7 7 1981`

case $? in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "Help pressed.";;
  3)
    echo "Hold pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: password ---
#!/bin/sh
# $Id: password,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
        --passwordbox "Hi, this is an password dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: infobox1 ---
#! /bin/sh
# $Id: infobox1,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

left=10
unit="seconds"
while test $left != 0
do

sleep 1
$DIALOG --title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by a sleep command in the shell script.
You have $left $unit to read this..." 10 52
left=`expr $left - 1`
test $left = 1 && unit="second"
done

--- NEW FILE: infobox3 ---
#! /bin/sh
# $Id: infobox3,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

left=10
unit="seconds"
while test $left != 0
do

$DIALOG --sleep 1 \
	--begin 5 0 \
	--title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 0 0
left=`expr $left - 1`
test $left = 1 && unit="second"
done

--- NEW FILE: infobox2 ---
#! /bin/sh
# $Id: infobox2,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

left=10
unit="seconds"
while test $left != 0
do

$DIALOG --sleep 1 \
	--title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 0 0
left=`expr $left - 1`
test $left = 1 && unit="second"
done

--- NEW FILE: timebox ---
#!/bin/sh
# $Id: timebox,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
USERTIME=`$DIALOG --title "TIMEBOX" --timebox "Please set the time..." 0 0 12 34 56 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "Time entered: $USERTIME.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: menubox1 ---
#!/bin/sh
# $Id: menubox1,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --default-item "OS/2" --clear --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" 2> $tempfile

retval=$?

case $retval in
  0)
    echo "`cat $tempfile` chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: progress2 ---
#!/bin/sh
# $Id: progress2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

ls -1 >$tempfile
(
while true
do
read text
test -z "$text" && break
ls -ld "$text"
sleep 1
done <$tempfile
) |

$DIALOG --title "PROGRESS" --progressbox "This is a detailed description\nof the progress-box." 20 70

--- NEW FILE: fselect ---
#!/bin/sh
# $Id: fselect,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
FILE=`$DIALOG --title "Please choose a file" --fselect $HOME/ 14 48 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "\"$FILE\" chosen";;
  1)
    echo "Button 1 (Cancel) pressed";;
  2)
    echo "Button 2 (Help) pressed";;
  3)
    echo "Button 3 (Extra) pressed";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: inputbox6-utf8 ---
#!/bin/sh
# $Id: inputbox6-utf8,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

case none"$LANG$LC_ALL$LC_CTYPE" in
*UTF-8*)
	;;
*)
	echo "This script must be run in a UTF-8 locale"
	exit 1
	;;
esac

$DIALOG \
--title    `printf "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"` \
--inputbox `printf "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"` \
10 20 2>$tempfile

retval=$?

case $retval in
  0)
    echo "Input string is \"`cat $tempfile`\"";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: timebox-stdout ---
#!/bin/sh
# $Id: timebox-stdout,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

USERTIME=`$DIALOG --stdout --title "TIMEBOX" --timebox "Please set the time..." 0 0 12 34 56`

case $? in
  0)
    echo "Time entered: $USERTIME.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: sourcemage.rc ---
# $Id: sourcemage.rc,v 1.1 2006-10-23 20:59:32 stsp Exp $
# Run-time configuration file for dialog, matches SourceMage color scheme.
#
# Types of values:
#
# Number     -  <number>
# String     -  "string"
# Boolean    -  <ON|OFF>
# Attribute  -  (foreground,background,highlight?)

# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 0

# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (RED,BLACK,ON)

# Shadow color
shadow_color = (BLACK,BLACK,ON)

# Dialog box color
dialog_color = (BLACK,WHITE,OFF)

# Dialog box title color
title_color = (RED,WHITE,ON)

# Dialog box border color
border_color = (WHITE,WHITE,ON)

# Active button color
button_active_color = (WHITE,RED,ON)

# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)

# Active button key color
button_key_active_color = (WHITE,RED,ON)

# Inactive button key color
button_key_inactive_color = (RED,WHITE,OFF)

# Active button label color
button_label_active_color = (RED,RED,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)

# Input box color
inputbox_color = (BLACK,WHITE,OFF)

# Input box border color
inputbox_border_color = (BLACK,WHITE,OFF)

# Search box color
searchbox_color = (BLACK,WHITE,OFF)

# Search box title color
searchbox_title_color = (RED,WHITE,ON)

# Search box border color
searchbox_border_color = (WHITE,WHITE,ON)

# File position indicator color
position_indicator_color = (RED,WHITE,ON)

# Menu box color
menubox_color = (BLACK,WHITE,OFF)

# Menu box border color
menubox_border_color = (WHITE,WHITE,ON)

# Item color
item_color = (BLACK,WHITE,OFF)

# Selected item color
item_selected_color = (WHITE,RED,ON)

# Tag color
tag_color = (RED,WHITE,ON)

# Selected tag color
tag_selected_color = (RED,RED,ON)

# Tag key color
tag_key_color = (RED,WHITE,ON)

# Selected tag key color
tag_key_selected_color = (WHITE,RED,ON)

# Check box color
check_color = (BLACK,WHITE,OFF)

# Selected check box color
check_selected_color = (WHITE,RED,ON)

# Up arrow color
uarrow_color = (RED,WHITE,ON)

# Down arrow color
darrow_color = (RED,WHITE,ON)

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = (BLACK,WHITE,OFF)

# Form text color
form_text_color = (RED,BLACK,ON)

--- NEW FILE: textbox2 ---
#!/bin/sh
# $Id: textbox2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

cat << EOF > $tempfile
Hi, this is a text dialog box. It can be used to display text from a file.
The file should not contain any 'tab' characters, so you should 'expand'
the file first if it contains 'tab' characters.

It's like a simple text file viewer, with these keys implemented:

PGDN/SPACE     - Move down one page
PGUP/'b'       - Move up one page
ENTER/DOWN/'j' - Move down one line
UP/'k'         - Move up one line
LEFT/'h'       - Scroll left
RIGHT/'l'      - Scroll right
'0'            - Move to beginning of line
HOME/'g'       - Move to beginning of file
END/'G'        - Move to end of file
'/'            - Forward search
'?'            - Backward search
'n'            - Repeat last search (forward)
'N'            - Repeat last search (backward)


The following is a sample text file:


EOF

TEXT=/usr/share/common-licenses/GPL
test -f $TEXT || TEXT=../COPYING

cat $TEXT | expand >> $tempfile

$DIALOG --clear --title "TEXT BOX" --textbox "$tempfile" 0 0

case $? in
  0)
    echo "OK";;
  1)
    echo "Button 1 (Cancel) pressed";;
  2)
    echo "Button 2 (Help) pressed";;
  3)
    echo "Button 3 (Extra) pressed";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: textbox3 ---
#!/bin/sh
# $Id: textbox3,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

TEXT=/usr/share/common-licenses/GPL
test -f $TEXT || TEXT=../COPYING

cat textbox.txt | expand > $tempfile
cat $TEXT | expand >> $tempfile

$DIALOG --clear --title "TEXT BOX" \
	--extra-button \
	--textbox "$tempfile" 22 77

case $? in
  0)
    echo "Button 0 (OK) pressed.";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: calendar2-stdout ---
#!/bin/sh
# $Id: calendar2-stdout,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

USERDATE=`$DIALOG --stdout --title "CALENDAR" --calendar "Please choose a date..." 0 0`

case $? in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: form6 ---
#! /bin/sh
# $Id: form6,v 1.1 2006-10-23 20:59:30 stsp Exp $
# form4 with --help-status
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --help-status \
	  --help-button \
	  --item-help \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 -9 9 "Login name" \
	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Help data:\n\
$show" 10 40
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: form5 ---
#! /bin/sh
# $Id: form5,v 1.1 2006-10-23 20:59:30 stsp Exp $
# form4 with --help-status
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --help-status \
	  --help-button \
	  --item-help \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 "Login name" \
	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Help data:\n\
$show" 10 40
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: infobox ---
#! /bin/sh
# $Id: infobox,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

left=10
unit="seconds"
while test $left != 0
do

$DIALOG --sleep 1 \
	--title "INFO BOX" \
        --infobox "Hi, this is an information box. It is
different from a message box: it will
not pause waiting for input after displaying
the message. The pause here is only introduced
by the sleep command within dialog.
You have $left $unit to read this..." 10 52
left=`expr $left - 1`
test $left = 1 && unit="second"
done

--- NEW FILE: gauge0-input-fd ---
#!/bin/sh
# $Id: gauge0-input-fd,v 1.1 2006-10-23 20:59:30 stsp Exp $
# modified "gauge0" script to use "--input-fd" option.
: ${DIALOG=dialog}

exec 3<&0
PCT=10
(
sleep 1
while test $PCT != 110
do
echo "XXX"
echo $PCT
echo "The new\n\
message ($PCT percent)"
echo "XXX"
PCT=`expr $PCT + 10`
sleep 1
done
) |

$DIALOG --title "GAUGE" --input-fd 3 --gauge "Hi, this is a gauge widget" 0 0 0

exec 3<&-

--- NEW FILE: gauge ---
#!/bin/sh
# $Id: gauge,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

PCT=10
(
while test $PCT != 100
do
echo "XXX"
echo $PCT
echo "The new\n\
message ($PCT percent)"
echo "XXX"
PCT=`expr $PCT + 10`
sleep 1
done
) |

$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 20 70 0

--- NEW FILE: inputbox-help ---
#!/bin/sh
# $Id: inputbox-help,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
	--help-button \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: inputbox4 ---
#!/bin/sh
# $Id: inputbox4,v 1.1 2006-10-23 20:59:31 stsp Exp $
# An example which does not use temporary files, as suggested by Cary Evans:
: ${DIALOG=dialog}

exec 3>&1
RESULT=`$DIALOG --title "INPUT BOX" --clear \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2>&1 1>&3`
retval=$?
exec 3>&-

case $retval in
  0)
    echo "Input string is $RESULT";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -n "$RESULT" ; then
      echo "$RESULT"
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: password1 ---
#!/bin/sh
# $Id: password1,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
	--insecure \
        --passwordbox "Hi, this is an password dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: password2 ---
#!/bin/sh
# $Id: password2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
	--insecure \
        --passwordbox "Hi, this is an password dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 stupid 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: inputbox7 ---
#!/bin/sh
# $Id: inputbox7,v 1.1 2006-10-23 20:59:31 stsp Exp $
# An example which produces two widget outputs.
: ${DIALOG=dialog}

MSG='Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:'

# separate with a line-break (newline)
SEP='
'

exec 3>&1
RESULT=`$DIALOG --title "INPUT BOX" --clear --separate-widget "$SEP" \
        --inputbox "$MSG" 16 51 \
	--title "ANOTHER INPUT BOX" \
        --inputbox "$MSG" 16 51 \
2>&1 1>&3`
retval=$?
exec 3>&-

case $retval in
  0)
    echo "Input string is $RESULT";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -n "$RESULT" ; then
      echo "$RESULT"
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: yesno ---
#!/bin/sh
# $Id: yesno,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "YES/NO BOX" --clear \
        --yesno "Hi, this is a yes/no dialog box. You can use this to ask \
                 questions that have an answer of either yes or no. \
                 BTW, do you notice that long lines will be automatically \
                 wrapped around so that they can fit in the box? You can \
                 also control line breaking explicitly by inserting \
                 'backslash n' at any place you like, but in this case, \
                 auto wrap around will be disabled and you will have to \
                 control line breaking yourself." 15 61

case $? in
  0)
    echo "Yes chosen.";;
  1)
    echo "No chosen.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: inputbox2 ---
#!/bin/sh
# $Id: inputbox2,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: inputbox3 ---
#!/bin/sh
# $Id: inputbox3,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --nocancel \
	--title "INPUT BOX" --clear \
        --inputbox "Hi, this is an input dialog box. You can use \n\
this to ask questions that require the user \n\
to input a string as the answer. You can \n\
input strings of length longer than the \n\
width of the input box, in that case, the \n\
input field will be automatically scrolled. \n\
You can use BACKSPACE to correct errors. \n\n\
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: tailboxbg2 ---
#!/bin/sh
# $Id: tailboxbg2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

./killall listing
./listing >listing.out &

$DIALOG --title "TAIL BOXES" \
	--no-kill \
	--begin 10 10 --tailboxbg listing.out 8 58 \
	--and-widget \
	--begin 15 15 --tailboxbg listing.out 8 58 \
	--and-widget \
	--begin 3 10 --msgbox "Press OK " 5 30 \
        2>$tempfile

# The --and-widget causes a tab to be emitted, but our example will only
# write one number to stderr.
pid=`cat $tempfile |sed -e 's/	//g'`
if test -n "$pid" ; then
# wait a while for the background process to run
sleep 10

# now kill it
kill -3 $pid 2>&1 >/dev/null 2>/dev/null
echo "killed [$pid]"
fi

# ...and the process that is making the listing
./killall listing

--- NEW FILE: rotated-data ---
#!/bin/sh
# $Id: rotated-data,v 1.1 2006-10-23 20:59:32 stsp Exp $
# Rotate the second parameter's data by the given shift count.
if test $# != 0
then
	case $1 in
	[1-9]*)
		left=$1
		next=`expr $left + 1`
		shift 1
		;;
	*)
		left=1
		next=2
		;;
	esac
	char=`echo "$@" | cut -b -${left}`
	data=`echo "$@" | cut -b ${next}-`

	printf "%s%s\n" $data $char
else
	echo
fi

--- NEW FILE: fselect1-stdout ---
#!/bin/sh
# $Id: fselect1-stdout,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

FILE=$HOME
for n in .cshrc .profile .bashrc
do
	if test -f $HOME/$n ; then
		FILE=$HOME/$n
		break
	fi
done

FILE=`$DIALOG --stdout --title "Please choose a file" --fselect $FILE 14 48`

case $? in
	0)
		echo "\"$FILE\" chosen";;
	1)
		echo "Cancel pressed.";;
	255)
		echo "Box closed.";;
esac

--- NEW FILE: tailboxbg1 ---
#!/bin/sh
# $Id: tailboxbg1,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

./killall listing
./listing >listing.out &

$DIALOG --title "TAIL BOXES" \
	--begin 10 10 --tailboxbg listing.out 8 58 \
	--and-widget \
	--begin 15 15 --tailboxbg listing.out 8 58 \
	--and-widget \
	--begin 3 10 --msgbox "Press OK " 5 30 \
        2>$tempfile

# The --and-widget causes a tab to be emitted, but our example will only
# write one number to stderr.
pid=`cat $tempfile |sed -e 's/	//g'`
if test -n "$pid" ; then
# wait a while for the background process to run
sleep 10

# now kill it
kill -3 $pid 2>&1 >/dev/null 2>/dev/null
echo "killed [$pid]"
fi

# ...and the process that is making the listing
./killall listing

--- NEW FILE: menubox-utf8 ---
#!/bin/sh
# $Id: menubox-utf8,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

case none"$LANG$LC_ALL$LC_CTYPE" in
*UTF-8*)
	;;
*)
	echo "This script must be run in a UTF-8 locale"
	exit 1
	;;
esac

$DIALOG --clear --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: copismall ---
#!/bin/bash
# $Id: copismall,v 1.1 2006-10-23 20:59:30 stsp Exp $
#
#  ComeOn Point Installer! v0.9a.small (small version for cdialog v0.9a)
#  - installa il point in modo visuale e auto-detecting. Versione light.
#
#  AUTHOR: Beppe (beppe.dem at nsm.it)
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

# THIS IS NOT THE ORIGINAL VERSION!!!! This files was adequate to be
# a demo for cdialog v0.9a+. However it doesn't include all its features.
# Look for one of the free ComeOn Linux! tools to have a complete
# demo of cdialog. ComeOn Linux! follows the GNU philosophy.
# Send peacefully a mail to demarco_p at abramo.it for more info.

: ${DIALOG=dialog}

#COMEONDIR=/usr/lib/ComeOn
#POINTDIR=$COMEONDIR/point
POINTDIR=`pwd`

AKASETUP=$POINTDIR/.akasetup
PNTSETUP=$POINTDIR/.pntsetup
EMSIFILE=$POINTDIR/.emsi
COPIUSER=$POINTDIR/.copi.user
COPIVER=v0.9a.small
TITLE="ComeOn Point Installer! $COPIVER  -+-  (c) 1996 ComeOn Linux!"

#FUNCSVER=v0.9.2
#FUNCSDIR=$POINTDIR/funcs-$FUNCSVER
FUNCSDIR=$POINTDIR/copifuncs

#COPIDIR=$POINTDIR/copi-$COPIVER
#. $COPIDIR/copishellvars

#POINTVER="v1.1"		# ComeOn Point version

if [ $LOGNAME != root ]
then
  $DIALOG --backtitle "$TITLE" --title "Error!" --beep --msgbox "Questo programma per funzionare correttamente deve essere avviato dall'amministratore di sistema (root)." 0 0
  exit
fi


$DIALOG --backtitle "$TITLE" --title "Are you sure?" --cr-wrap --msgbox "Questo installer procedera' in modalita'
auto-detect all'installazione del point.
Premi <Enter> per iniziare o <Esc> per uscire. " 0 0

if [ $? = 1 -o $? = 255 ]; then
 exit
fi


pushd $FUNCSDIR >/dev/null
. ./copi.funcs
. ./common.funcs
. ./admin.funcs

###############################################################################
find_incompatible_packages

if [ "$PKG_TO_REMOVE" ]
then
  $DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "Attenzione, prima di poter continuare bisogna avviare pkgtool e rimuovere i seguenti packages: $PKG_TO_REMOVE." 0 0
  exit
fi

###############################################################################
mkstemp dialog

find_necessary_packages

if [ "$PKG_TO_INSTALL" ]
then
  echo -n "Attenzione, prima di poter continuare bisogna avviare setup ed installare i seguenti packages dai disk sets N (quelli del Networking): $PKG_TO_INSTALL." >$tmp_dialog

  if [ "`echo $PKG_TO_INSTALL | grep tcpip`" ]
  then
    echo -n " Ricordarsi poi di effettuare lo shutdown per rendere effettive le modifiche." >>$tmp_dialog
  fi

  $DIALOG --backtitle "$TITLE" --beep --title "Problem detected" --msgbox "`cat $tmp_dialog`" 0 0

  rm $tmp_dialog
  exit
fi

###############################################################################
mkstemp smailp

SMAILTGZ=""
if [ ! -d /usr/lib/smail ]
then
  $DIALOG --backtitle "$TITLE" --title "Smail not found" --inputbox "Bisogna installare Smail, per cui inserire il percorso completo di dove trovarne i binari compressi" 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
  SMAILTGZ="`cat $tmp_smailp`"
  rm $tmp_smailp
  while [ ! -f "$SMAILTGZ" ]
  do
    $DIALOG --backtitle "$TITLE" --beep --title "Archive not found" --inputbox "Percorso di file \"$SMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/delivery/smail-linuxbin-3.1.29.1.tar.gz" 2>$tmp_smailp
    SMAILTGZ="`cat $tmp_smailp`"
    rm $tmp_smailp
  done
fi

###############################################################################
mkstemp target
mkstemp asetup
mkstemp psetup

AKA=""
while [ ! "$AKA" ]
do
  $DIALOG --backtitle "$TITLE" --title "Primary address" --inputbox "Inserire il proprio address principale, completo di point e di domain. Il poll sara' effettuato per default dal boss corrispondente." 0 0 "2:335/722.7 at fidonet" 2>$tmp_target
  AKAFTN="`cat $tmp_target`"
  rm $tmp_target
  fidonetpoint2int $AKAFTN
  AKA="$_RETVAL"
done
echo -n "`echo $AKA | cut -f2- -d.`:" >$tmp_asetup
echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >$tmp_psetup
AKASFTN="$AKAFTN"
AKAS="$AKA"
while [ "$AKAFTN" ]
do
  $DIALOG --backtitle "$TITLE" --title "AKAs" --inputbox "Inserire un eventuale address secondario, oppure lasciare la riga vuota per proseguire. Attenzione: nel caso si abbiano piu' indirizzi sulla stessa rete, bisognera' configurare solo uno di questi.  Gli indirizzi correntemente definiti sono: $AKASFTN" 0 0 2>$tmp_target
  AKAFTN="`cat $tmp_target`"
  rm $tmp_target
  if [ "$AKAFTN" ]
  then
    fidonetpoint2int $AKAFTN
    AKA="$_RETVAL"
    if [ "`echo $AKAS | grep \".\`echo $AKA | cut -f5 -d.\`.\"`" ]
    then
      $DIALOG --backtitle "$TITLE" --beep --title "Invalid address" --msgbox "Non si possono avere piu' indirizzi sullo stesso dominio (net)." 0 0
    else
      AKASFTN="$AKASFTN $AKAFTN"
      AKAS="$AKAS $AKA"
      echo -n "`echo $AKA | cut -f2- -d.`:" >>$tmp_asetup
      echo -n "`echo $AKA | cut -f1 -d. | cut -c2-`:" >>$tmp_psetup
    fi
  fi
done
echo ":" >>$tmp_asetup
echo ":" >>$tmp_psetup
save $AKASETUP
save $PNTSETUP
mv $tmp_asetup $AKASETUP
mv $tmp_psetup $PNTSETUP

###############################################################################
mkstemp hostnm

$DIALOG --backtitle "$TITLE" --title "Hostname" --inputbox "Inserire l'hostname di questo computer qualora si abbia una rete gia' configurata, altrimenti inventarne uno fittizio da assegnare e questa macchina verra' configurata per il loopback." 0 0 "quark.comeon.org" 2>$tmp_hostnm
NEW_HOSTNAME="`cat $tmp_hostnm`"
rm $tmp_hostnm

###############################################################################
mkstemp master

$DIALOG --backtitle "$TITLE" --title "Point admin" --inputbox "Scegliere l'user principale per la gestione e l'uso del point. Se l'user non esiste, verra' creato. Se esiste, ne verranno adattate le informazioni quali nome, gruppi, etc." 0 0 "beppe" --and-widget --title "Insert SysOp's name" --inputbox "Inserire nome e cognome del gestore ed utilizzatore principale del point (il proprio nome)." 0 0 "Giuseppe De Marco" --and-widget --title "Choose editor" --inputbox "Scegliere l'editor da usare per scrivere i messaggi" 0 0 "vim" 2>$tmp_master
POST_USER="`cut $tmp_master -f1`"
POST_NAME="`cut $tmp_master -f2`"
POST_EDIT="`cut $tmp_master -f3`"
rm $tmp_master
save $COPIUSER
echo $POST_USER >$COPIUSER

###############################################################################
mkstemp expire
mkstemp origin

$DIALOG --backtitle "$TITLE" --title "Origin" --inputbox "Scegliere l'Origin del sistema" 9 60 "$POST_USER's linux box" 2>$tmp_origin
NEW_ORIGIN="`cat $tmp_origin`"
rm $tmp_origin

$DIALOG --backtitle "$TITLE" --title "News expiring" --inputbox "Decidere per quanti giorni i messaggi echomail (le news) dovranno transitare sul sistema prima di venire cancellati automaticamente da news.daily. Inserire never se si vuole che non vengano mai cancellati. Sono ammesse cifre decimali (i.e. 25.5).  Notare comunque che il valore qui inserito e' quello di default, ma per ogni singola area (newsgroup) sara' possibile specificare poi un valore appropriato." 0 0 "30" 2>$tmp_expire
KEEPDAYS="`cat $tmp_expire`"
rm $tmp_expire

###############################################################################
mkstemp dialer
mkstemp ifmail
mkstemp mailvr
mkstemp passwd

IFMAILTGZ=""
IFMAILVERS=""
if [ ! -d /usr/lib/ifmail -o ! -d /etc/ifmail -o ! -d /var/log/ifmail -o ! -f /usr/lib/ifmail/ifcico ]
then
  $DIALOG --backtitle "$TITLE" --title "ifmail not found" --inputbox "Inserire il percorso COMPLETO dei sorgenti compressi di ifmail che verranno decompressi in /usr/src e compilati." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
  IFMAILTGZ="`cat $tmp_ifmail`"
  rm $tmp_ifmail
  while [ ! -f "$IFMAILTGZ" ]
  do
    $DIALOG --backtitle "$TITLE" --beep --title "invalid filename" --inputbox "Percorso di file \"$IFMAILTGZ\" non valido, controllarne la correttezza." 0 0 "/cdrom/sunsite/system/Mail/transport/ifmail-2.8b.tar.gz" 2>$tmp_ifmail
    IFMAILTGZ="`cat $tmp_ifmail`"
    rm $tmp_ifmail
  done

  $DIALOG --backtitle "$TITLE" --title "ifmail version" --inputbox "Specificare la versione di ifmail" 0 0 "2.8b" 2>$tmp_mailvr
  IFMAILVERS="`cat $tmp_mailvr` + ComeOn Point $POINTVER"
  rm $tmp_mailvr
fi

IAKA=1
PASSW=""
AKA="`cut $AKASETUP -f$IAKA -d:`"
while [ "$AKA" ]
do
  int2fido $AKA
  AKAFTN="$_RETVAL"
  $DIALOG --backtitle "$TITLE" --title "Password" --inputbox "Specificare la password di sessione e per i pacchetti per il nodo $AKAFTN -- attenzione che alcuni mailers accettano solo passwords da 8 caratteri in maiuscolo!!" 0 0 "MYPASSWD" 2>$tmp_passwd
  PASSW="$PASSW`cat $tmp_passwd`:"
  rm $tmp_passwd
  IAKA=$[$IAKA+1]
  AKA="`cut $AKASETUP -f$IAKA -d:`"
done
PASSW="$PASSW:"

$DIALOG --backtitle "$TITLE" \
--title "Modem speed" --inputbox "Specificare la velocita' del proprio modem (che sta su /dev/modem)" 0 0 "16800" --and-widget \
--title "System name" --inputbox "Specificare il nome del sistema per il pacchetto EMSI" 0 0 "`cat $COPIUSER`'s linux point" --and-widget \
--title "Location" --inputbox "Inserire la localita' fisica in cui risiede il sistema" 0 0 "Catanzaro, Italy - Europe" --and-widget \
--title "Phone number" --inputbox "Inserire il proprio numero di telefono in formato internazionale, cioe' completo di doppio prefisso (xx-yyy-zzzzzz)" 0 0 "39-961-31997" --and-widget \
--title "International call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata internazionale (se ci si trova in Italia ad es. bisogna inserire 00)" 0 0 "00" --and-widget \
--title "Long-distance call prefix" --inputbox "Specificare il prefisso da comporre per poter effettuare una chiamata interurbana in ambito nazionale, che verra' sostituito al prefisso della propria nazione quando incontrato in nodelist (per l'Italia ad es. bisogna inserire 0, che sostituira' il 39)" 0 0 "0" --and-widget \
--title "Pointlist flags" --inputbox "Inserire eventuali flags stile pointlist per il pacchetto EMSI" 0 0 "MO,V32B,V42B,ZYX" --and-widget \
--title "Modem dialing" --inputbox "Inserire la stringa da inviare al modem per comporre un numero telefonico" 0 0 "ATDT" 2>$tmp_dialer

echo -en "\t$POST_NAME\t\t" >>$tmp_dialer
save $EMSIFILE
mv $tmp_dialer $EMSIFILE

###############################################################################

if [ -d /etc/smail ]
then
  SMAILCFGDIR=/etc/smail
else
  SMAILCFGDIR=/usr/lib/smail
fi

###############################################################################

$DIALOG --backtitle "$TITLE" --title "First step completed!" --msgbox "OK, ora ho tutte le informazioni necessarie per poter installare il point. Da qui in poi faro' tutto da solo, quindi ci si puo' tranquillamente andare a prendere un caffe'. :-)" 0 0

###############################################################################

killall sendmail 2>/dev/null
if [ $SMAILTGZ ]; then tar zxvf $SMAILTGZ -C / >/dev/null; fi
/usr/sbin/sendmail -bd -q15m

if [ ! "`ping -c1 $NEW_HOSTNAME | grep \"1 packets received\"`" ]; then
  configure_loopback $NEW_HOSTNAME
fi

add_postmaster "$POST_USER" "$POST_NAME"
add_alias "$POST_NAME" "$POST_USER"
configure_trn "$POST_USER" "$POST_EDIT"
configure_elm "$POST_USER" "$POST_EDIT"

comment_nntp_in_inetdconf
set_organization "$NEW_ORIGIN"
create_innconf_newsfeeds_distrib
create_expirectl $KEEPDAYS
create_nnrpaccess
create_hostsnntp
create_dirs_and_files
install_rcnews
install_crontab_news
if [ $IFMAILTGZ ]; then
  install_ifmail "$IFMAILTGZ" /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$IFMAILVERS" /usr/src
fi
configure_ifmail /usr/lib/ifmail /etc/ifmail /var/log/ifmail "$PASSW"
configure_smail $SMAILCFGDIR

###############################################################################
$DIALOG --backtitle "$TITLE" \
--title "-=[ Enjoy! ]=-" --msgbox "Il point e' stato installato con successo!" 0 0 --and-widget \
--msgbox "trn (il newsreader, per leggere/scrivere gli echomail) ed elm (il mailreader, per leggere/scrivere i netmail) sono gia' stati configurati per l'user $POST_USER." 0 0

popd >/dev/null

--- NEW FILE: msgbox1 ---
#!/bin/sh
# $Id: msgbox1,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "MESSAGE BOX" --clear \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with dialogs default aspect ratio of 9." 0 0
test $? = 255 && exit

$DIALOG --aspect 12 --title "MESSAGE BOX  aspect=12" --clear \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with an aspect ratio of 12." 0 0
test $? = 255 && exit

$DIALOG --aspect 6 --title "MESSAGE BOX  aspect=6" --clear \
        --msgbox "Hi, this is a simple message box. You can use this to 
                  display any message you like. The box will remain until
                  you press the ENTER key.  This box is being displayed 
                  with an aspect ratio of 6." 0 0
test $? = 255 && exit

$DIALOG --aspect 6 --cr-wrap --title "MESSAGE BOX aspect=6 with --cr-wrap" \
        --clear --msgbox "\
           Hi, this is a simple
           message box. You can
          use this to display any 
             message you like.
The box will remain until you press the ENTER key.  This box is being displayed with an aspect ratio of 6, and using --cr-wrap.\n" 0 0
test $? = 255 && exit

--- NEW FILE: tailboxbg ---
#!/bin/sh
# $Id: tailboxbg,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

./killall listing
./listing >listing.out &

$DIALOG --title "TAIL BOX" \
	--no-kill \
        --tailboxbg listing.out 24 70 2>$tempfile

# wait a while for the background process to run
sleep 10

# now kill it
kill -3 `cat $tempfile` 2>&1 >/dev/null 2>/dev/null

# ...and the process that is making the listing
./killall listing

--- NEW FILE: calendar ---
#!/bin/sh
# $Id: calendar,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
USERDATE=`$DIALOG --title "CALENDAR" --calendar "Please choose a date..." 0 0 7 7 1981 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: inputbox6-8bit ---
#!/bin/sh
# $Id: inputbox6-8bit,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

. ./testdata-8bit

$DIALOG \
--title    `printf "$SAMPLE"` \
--inputbox `printf "$SAMPLE"` \
10 40 `printf "$SAMPLE"` 2>$tempfile

retval=$?

case $retval in
  0)
    echo "Input string is \"`cat $tempfile`\"";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: timebox2 ---
#!/bin/sh
# $Id: timebox2,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
USERTIME=`$DIALOG --title "TIMEBOX" --timebox "Please set the time..." 0 0 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
  0)
    echo "Time entered: $USERTIME.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: fselect2 ---
#!/bin/sh
# $Id: fselect2,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

exec 3>&1
FILE=`$DIALOG --title "Please choose a file" --fselect $HOME/ 0 0 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
	0)
		echo "\"$FILE\" chosen";;
	1)
		echo "Cancel pressed.";;
	255)
		echo "Box closed.";;
esac

--- NEW FILE: form1-help ---
#! /bin/sh
# $Id: form1-help,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --help-button \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		echo "Button 2 (Help) pressed."
		exit
		;;
	3)
		echo "Button 3 (Extra) pressed."
		exit
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: gauge3 ---
#!/bin/sh
# $Id: gauge3,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

(
sleep 1
for n in 0 1 2 3 4 5 4 3 2 1 0
do
PCT=`expr $n \* $n \* 4`
echo "XXX"
echo $PCT
echo "The new\n\
message ($PCT percent)"
echo "XXX"
sleep 1
done
) |

$DIALOG --title "GAUGE" --gauge "Hi, this is a gauge widget" 10 70 0

--- NEW FILE: msgbox4-utf8 ---
#!/bin/sh
# $Id: msgbox4-utf8,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

case none"$LANG$LC_ALL$LC_CTYPE" in
*UTF-8*)
	;;
*)
	echo "This script must be run in a UTF-8 locale"
	exit 1
	;;
esac

width=30
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --no-collapse \
        --msgbox "\
This sample is written in UTF-8.
There are several checking points:
(1) whether the fullwidth characters are displayed well or not,
(2) whether the width of characters are evaluated properly, and
(3) whether the character at line-folding is lost or not.

あいうえおかきくけこさしすせそたちつてとなにぬねの
1234567890123456789012345
ABCDEFGHIJKLMNOPQRSTUVWXY

Hi, this is a simple message box.  You can use this to \
display any message you like.  The box will remain until \
you press the ENTER key." 22 $width
retval=$?

case $retval in
  $DIALOG_CANCEL)
    echo "Cancel pressed.";exit;;
  $DIALOG_ESC)
    echo "ESC pressed.";exit;;
esac

width=`expr $width + 1`

done

--- NEW FILE: form2 ---
#! /bin/sh
# $Id: form2,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
0 0 10 \
	"1 Username:"  1 1	"$user" 1  12 10 10 \
	"1 UID:"       2 1	"$uid"  2  12 10 10 \
	"1 GID:"       3 1	"$gid"  3  12 10 10 \
	"1 HOME:"      4 1	"$home" 4  12 10 10 \
	"2 Username:"  5 1	"$user" 5  12 10 10 \
	"2 UID:"       6 1	"$uid"  6  12 10 10 \
	"2 GID:"       7 1	"$gid"  7  12 10 10 \
	"2 HOME:"      8 1	"$home" 8  12 10 10 \
	"3 Username:"  9 1	"$user" 9  12 10 10 \
	"3 UID:"      10 1	"$uid"  10 12 10 10 \
	"3 GID:"      11 1	"$gid"  11 12 10 10 \
	"3 HOME:"     12 1	"$home" 12 12 10 10 \
	"4 Username:" 13 1	"$user" 13 12 10 10 \
	"4 UID:"      14 1	"$uid"  14 12 10 10 \
	"4 GID:"      15 1	"$gid"  15 12 10 10 \
	"4 HOME:"     16 1	"$home" 16 12 10 10 \
	"5 Username:" 17 1	"$user" 17 12 10 10 \
	"5 UID:"      18 1	"$uid"  18 12 10 10 \
	"5 GID:"      19 1	"$gid"  19 12 10 10 \
	"5 HOME:"     20 1	"$home" 20 12 10 10 \
	"6 Username:" 21 1	"$user" 21 12 10 10 \
	"6 UID:"      22 1	"$uid"  22 12 10 10 \
	"6 GID:"      23 1	"$gid"  23 12 10 10 \
	"6 HOME:"     24 1	"$home" 24 12 10 10 \
	"7 Username:" 25 1	"$user" 25 12 10 10 \
	"7 UID:"      26 1	"$uid"  26 12 10 10 \
	"7 GID:"      27 1	"$gid"  27 12 10 10 \
	"7 HOME:"     28 1	"$home" 28 12 10 10 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 0 0
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: form1-extra ---
#! /bin/sh
# $Id: form1-extra,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --extra-button \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		echo "Button 2 (Help) pressed."
		exit
		;;
	3)
		echo "Button 3 (Extra) pressed."
		exit
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: inputbox-extra ---
#!/bin/sh
# $Id: inputbox-extra,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
	--extra-button \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: fselect-stdout ---
#!/bin/sh
# $Id: fselect-stdout,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

FILE=`$DIALOG --stdout --title "Please choose a file" --fselect $HOME/ 14 48`

case $? in
	0)
		echo "\"$FILE\" chosen";;
	1)
		echo "Cancel pressed.";;
	255)
		echo "Box closed.";;
esac

--- NEW FILE: form1 ---
#! /bin/sh
# $Id: form1,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 \
	"UID:"      2 1	"$uid"  2 10  8 0 \
	"GID:"      3 1	"$gid"  3 10  8 0 \
	"HOME:"     4 1	"$home" 4 10 40 0 \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		echo "Button 2 (Help) pressed."
		exit
		;;
	3)
		echo "Button 3 (Extra) pressed."
		exit
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: checklist8 ---
#! /bin/sh
# $Id: checklist8,v 1.1 2006-10-23 20:59:29 stsp Exp $
# "checklist7" without --item-help
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button \
	--colors \
	--backtitle "\Z1No Such\Zn Organization" \
	--separate-output \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
\Z4UP/DOWN\Zn arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press \Zb\ZrSPACE\Zn to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an \Z1apple\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                    off \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off \
        ""           "No such pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            off \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  \
        "Fish"       "Cats like \Z4fish\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                   On  \
        "Lemon"      "You know how it \Zr\Zb\Z3tastes\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"     on  2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: menubox10 ---
#!/bin/sh
# $Id: menubox10,v 1.1 2006-10-23 20:59:31 stsp Exp $
# zero-width column
: ${DIALOG=dialog}

exec 3>&1
value=`$DIALOG --backtitle "Debian Configuration" \
	--title "Configuring debconf" \
	--default-item Dialog \
	--menu "Packages that use debconf for co" 19 50 6 \
	Dialog		"" \
	Readline	"" \
	Gnome		"" \
	Kde		"" \
	Editor		"" \
	Noninteractive	"" \
2>&1 1>&3`
retval=$?
exec 3>&-

case $retval in
  0)
    echo "$value chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "Help pressed ($value)";;
  255)
    if test -n "$value" ; then
      echo "$value"
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: fselect1 ---
#!/bin/sh
# $Id: fselect1,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

FILE=$HOME
for n in .cshrc .profile .bashrc
do
	if test -f $HOME/$n ; then
		FILE=$HOME/$n
		break
	fi
done

exec 3>&1
FILE=`$DIALOG --title "Please choose a file" --fselect $FILE 14 48 2>&1 1>&3`
code=$?
exec 3>&-

case $code in
	0)
		echo "\"$FILE\" chosen";;
	1)
		echo "Cancel pressed.";;
	255)
		echo "Box closed.";;
esac

--- NEW FILE: yesno2 ---
#!/bin/sh
# $Id: yesno2,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "YES/NO BOX" \
        --yesno "Hi, this is a yes/no dialog box. You can use this to ask \
questions that have an answer of either yes or no. \
BTW, do you notice that long lines will be automatically \
wrapped around so that they can fit in the box? You can \
also control line breaking explicitly by inserting \
'backslash n' at any place you like, but in this case, \
auto wrap around will be disabled and you will have to \
control line breaking yourself." 0 0

case $? in
  0)
    echo "Yes chosen.";;
  1)
    echo "No chosen.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: yesno3 ---
#!/bin/sh
# $Id: yesno3,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --timeout 20 --title "YES/NO BOX" \
        --yesno "Hi, this is a yes/no dialog box. You can use this to ask \
questions that have an answer of either yes or no. \
BTW, do you notice that long lines will be automatically \
wrapped around so that they can fit in the box? You can \
also control line breaking explicitly by inserting \
'backslash n' at any place you like, but in this case, \
auto wrap around will be disabled and you will have to \
control line breaking yourself." 0 0

case $? in
  0)
    echo "Yes chosen.";;
  1)
    echo "No chosen.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: killall ---
#! /bin/sh
# $Id: killall,v 1.1 2006-10-23 20:59:31 stsp Exp $
# Linux has a program that does this correctly.
for prog in $*
do
	pid=`ps -a |fgrep $prog |fgrep -v fgrep|sed -e 's/^[ ]*//' -e 's/ .*//' `
	if test -n "$pid" ; then
		echo killing pid=$pid, $prog
		kill -1 $pid || \
		kill -15 $pid || \
		kill -9 $pid
	fi
done

--- NEW FILE: inputmenu-stdout ---
#! /bin/bash
# $Id: inputmenu-stdout,v 1.1 2006-10-23 20:59:31 stsp Exp $
# 2002 - written by Tobias Rittweiler <tobrit at freebits.de>
: ${DIALOG=dialog}

user="$USER"    ; uid="$UID"   ;
gid="$GROUPS"  ; home="$HOME"  ;

while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
       value="$("$DIALOG" --stdout --clear --ok-label "Create" \
                          --backtitle "An Example for the use of --inputmenu:" \
                          --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program.
" 20 50 10 "Username:" "$user" "UID:" "$uid" "GID:" "$gid" "HOME:" "$home")"
       returncode=$?
       case $returncode in
           1)
               "$DIALOG"  --clear --backtitle "An Example for the use of --inputmenu:" \
                               --yesno "Really quit?" 10 30
               case $? in
                       0) break;;
                       1) returncode=99;;
               esac
               ;;
           0)
               "$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:"  \
			--msgbox "useradd \n\
				-d $home \n\
				-u $uid \n\
				-g $gid \n\
				$user" 10 40
               ;;
           3)
               value="${value:8:${#value}}"
               tag="${value%:*}"
               item="${value#*: }"

               case "$tag" in
                       Username) user="$item";;
                       UID) uid="$item";;
                       GID) gid="$item";;
                       HOME) home="$item";;
               esac
	       ;;

       255)
                echo "ESC pressed."
                break
                ;;

       esac
done

--- NEW FILE: progress ---
#!/bin/sh
# $Id: progress,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

ls -1 >$tempfile
(
while true
do
read text
test -z "$text" && break
ls -ld "$text"
sleep 1
done <$tempfile
) |

$DIALOG --title "PROGRESS" --progressbox 20 70

--- NEW FILE: textbox ---
#!/bin/sh
# $Id: textbox,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

cat << EOF > $tempfile
Hi, this is a text dialog box. It can be used to display text from a file.
The file should not contain any 'tab' characters, so you should 'expand'
the file first if it contains 'tab' characters.

It's like a simple text file viewer, with these keys implemented:

PGDN/SPACE     - Move down one page
PGUP/'b'       - Move up one page
ENTER/DOWN/'j' - Move down one line
UP/'k'         - Move up one line
LEFT/'h'       - Scroll left
RIGHT/'l'      - Scroll right
'0'            - Move to beginning of line
HOME/'g'       - Move to beginning of file
END/'G'        - Move to end of file
'/'            - Forward search
'?'            - Backward search
'n'            - Repeat last search (forward)
'N'            - Repeat last search (backward)


The following is a sample text file:


EOF

TEXT=/usr/share/common-licenses/GPL
test -f $TEXT || TEXT=../COPYING

cat $TEXT | expand >> $tempfile

$DIALOG --clear --title "TEXT BOX" --textbox "$tempfile" 22 77

case $? in
  0)
    echo "OK";;
  1)
    echo "Button 1 (Cancel) pressed";;
  2)
    echo "Button 2 (Help) pressed";;
  3)
    echo "Button 3 (Extra) pressed";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: pause-help ---
#!/bin/sh
# $Id: pause-help,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "PAUSE" \
	--help-button \
	--pause "Hi, this is a pause widget" 20 70 10

retval=$?

case $retval in
  0)
    echo "Timeout expired.";;
  1)
    echo "Button 1 (Cancel) pressed.";;
  2)
    echo "Button 2 (Help) pressed.";;
  3)
    echo "Button 3 (Extra) pressed.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected return code: $retval";;
esac

--- NEW FILE: menubox ---
#!/bin/sh
# $Id: menubox,v 1.1 2006-10-23 20:59:31 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --clear --title "MENU BOX" \
        --menu "Hi, this is a menu box. You can use this to \n\
present a list of choices for the user to \n\
choose. If there are more items than can fit \n\
on the screen, the menu will be scrolled. \n\
You can use the UP/DOWN arrow keys, the first \n\
letter of the choice as a hot key, or the \n\
number keys 1-9 to choose an option.\n\
Try it now!\n\n\
          Choose the OS you like:" 20 51 4 \
        "Linux"  "The Great Unix Clone for 386/486" \
        "NetBSD" "Another free Unix Clone for 386/486" \
        "OS/2" "IBM OS/2" \
        "WIN NT" "Microsoft Windows NT" \
        "PCDOS"  "IBM PC DOS" \
        "MSDOS"  "Microsoft DOS" 2> $tempfile

retval=$?

choice=`cat $tempfile`

case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: wheel ---
#!/bin/sh
# $Id: wheel,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$

TITLE="This screen was taken from ComeOn Point Installer! v0.9 by ComeOn Linux!"

$DIALOG --print-maxsize 2>$tempfile
ROWS="`cut $tempfile -f1 -d, | cut -f2 -d:`"
COLS="`cut $tempfile -f2 -d,`"
rm $tempfile

# account for widest labels
COLS=`expr $COLS - 30`

# Takes an integer, multiplies it for COLS, divides for 132
scalex() {
  echo $[$1*$COLS/132]
}
scaley() {
  echo $[$1*$ROWS/60]
}

$DIALOG --backtitle "$TITLE" --no-shadow \
--begin `scaley 27` `scalex 98` --infobox "pushd /var/log >/dev/null" 0 0 --and-widget \
--begin `scaley 35` `scalex 95` --infobox "mkdir -p news -m 755" 0 0 --and-widget \
--begin `scaley 45` `scalex 86` --infobox "chown news.news news" 0 0 --and-widget \
--begin `scaley 48` `scalex 78` --infobox "cd /var/log/news" 0 0 --and-widget \
--begin `scaley 51` `scalex 61` --infobox "mkdir -p OLD -m 755" 0 0 --and-widget \
--begin `scaley 52` `scalex 47` --infobox "chown news.news OLD" 0 0 --and-widget \
--begin `scaley 51` `scalex 40` --infobox "cd /var/spool" 0 0 --and-widget \
--begin `scaley 48` `scalex 25` --infobox "mkdir -p news -m 775" 0 0 --and-widget \
--begin `scaley 42` `scalex 13` --infobox "chown news.news news" 0 0 --and-widget \
--begin `scaley 35` `scalex 4` --infobox "cd /var/spool/news" 0 0 --and-widget \
--begin `scaley 27` `scalex 2` --infobox "CURMASK=`umask`" 0 0 --and-widget \
--begin `scaley 19` `scalex 4` --infobox "umask 02" 0 0 --and-widget \
--begin `scaley 11` `scalex 13` --infobox "mkdir -p out.going control junk in.coming" 0 0 --and-widget \
--begin `scaley 5` `scalex 25` --infobox "chown news.news out.going control junk in.coming" 0 0 --and-widget \
--begin `scaley 2` `scalex 37` --infobox "cd in.coming" 0 0 --and-widget \
--begin `scaley 1` `scalex 46` --infobox "mkdir -p bad tmp" 0 0 --and-widget \
--begin `scaley 2` `scalex 61` --infobox "chown news.news bad tmp" 0 0 --and-widget \
--begin `scaley 5` `scalex 76` --infobox "umask $CURMASK" 0 0 --and-widget \
--begin `scaley 11` `scalex 87` --infobox "ln -sf ~news /usr/local/lib/" 0 0 --and-widget \
--begin `scaley 18` `scalex 95` --infobox "ln -sf ~news/inews /usr/bin/" 0 0 --and-widget \
--begin `scaley 26` `scalex 97` --infobox "chmod 1777 /var/tmp" 0 0 --and-widget \
--begin `scaley 34` `scalex 95` --infobox "cd ~news" 0 0 --and-widget \
--begin `scaley 42` `scalex 87` --infobox "touch history history.dir history.pag errlog log" 0 0 --and-widget \
--begin `scaley 47` `scalex 76` --infobox "chown news.news history* log errlog" 0 0 --and-widget \
--infobox "Creating spooling and logging directories and files..." 0 0 --and-widget \
--begin `scaley 51` `scalex 78` --infobox "chmod 664 history* log errlog" 0 0 --and-widget \
--begin `scaley 52` `scalex 60` --infobox "echo \"control 0000000000 0000000001 y\" > active" 0 0 --and-widget \
--begin `scaley 51` `scalex 42` --infobox "echo \"junk 0000000000 0000000001 y\" >> active" 0 0 --and-widget \
--begin `scaley 48` `scalex 26` --infobox "chown news.news active" 0 0 --and-widget \
--begin `scaley 42` `scalex 13` --infobox "echo \"control 814573260 usenet\" > active.times" 0 0 --and-widget \
--begin `scaley 35` `scalex 4` --infobox "echo \"junk 814573260 usenet\" >> active.times" 0 0 --and-widget \
--begin `scaley 27` `scalex 2` --infobox "chown news.news active.times" 0 0 --and-widget \
--begin `scaley 19` `scalex 4` --infobox ":>newsgroups" 0 0 --and-widget \
--begin `scaley 11` `scalex 12` --infobox "chown news.news newsgroups" 0 0 --and-widget \
--sleep 2 --begin `scaley 6` `scalex 25` --infobox "popd >/dev/null" 0 0 --and-widget \
--beep --msgbox "ComeOn Linux! :-)" 0 0 --and-widget \
--begin 2 0 --title "/var/adm/debug. This is running while that down runs also" --tailboxbg /var/adm/debug 6 80 --and-widget \
--begin 8 0 --title "/var/adm/messages. It tails the file in multitasking with /var/adm/debug" --tailbox /var/adm/messages -1 -1

--- NEW FILE: debian.rc ---
# $Id: debian.rc,v 1.1 2006-10-23 20:59:30 stsp Exp $
# Run-time configuration file for dialog, matches Debian color scheme.
# (these are the default values for dialog)

# Set aspect-ration.
aspect = 0

# Set separator (for multiple widgets output).
separate_widget = ""

# Set tab-length (for textbox tab-conversion).
tab_len = 0

# Make tab-traversal for checklist, etc., include the list.
visit_items = OFF

# Shadow dialog boxes? This also turns on color.
use_shadow = ON

# Turn color support ON or OFF
use_colors = ON

# Screen color
screen_color = (CYAN,BLUE,ON)

# Shadow color
shadow_color = (BLACK,BLACK,ON)

# Dialog box color
dialog_color = (BLACK,WHITE,OFF)

# Dialog box title color
title_color = (BLUE,WHITE,ON)

# Dialog box border color
border_color = (WHITE,WHITE,ON)

# Active button color
button_active_color = (WHITE,BLUE,ON)

# Inactive button color
button_inactive_color = (BLACK,WHITE,OFF)

# Active button key color
button_key_active_color = (WHITE,BLUE,ON)

# Inactive button key color
button_key_inactive_color = (RED,WHITE,OFF)

# Active button label color
button_label_active_color = (YELLOW,BLUE,ON)

# Inactive button label color
button_label_inactive_color = (BLACK,WHITE,ON)

# Input box color
inputbox_color = (BLACK,WHITE,OFF)

# Input box border color
inputbox_border_color = (BLACK,WHITE,OFF)

# Search box color
searchbox_color = (BLACK,WHITE,OFF)

# Search box title color
searchbox_title_color = (BLUE,WHITE,ON)

# Search box border color
searchbox_border_color = (WHITE,WHITE,ON)

# File position indicator color
position_indicator_color = (BLUE,WHITE,ON)

# Menu box color
menubox_color = (BLACK,WHITE,OFF)

# Menu box border color
menubox_border_color = (WHITE,WHITE,ON)

# Item color
item_color = (BLACK,WHITE,OFF)

# Selected item color
item_selected_color = (WHITE,BLUE,ON)

# Tag color
tag_color = (BLUE,WHITE,ON)

# Selected tag color
tag_selected_color = (YELLOW,BLUE,ON)

# Tag key color
tag_key_color = (RED,WHITE,OFF)

# Selected tag key color
tag_key_selected_color = (RED,BLUE,ON)

# Check box color
check_color = (BLACK,WHITE,OFF)

# Selected check box color
check_selected_color = (WHITE,BLUE,ON)

# Up arrow color
uarrow_color = (GREEN,WHITE,ON)

# Down arrow color
darrow_color = (GREEN,WHITE,ON)

# Item help-text color
itemhelp_color = (WHITE,BLACK,OFF)

# Active form text color
form_active_text_color = (WHITE,BLUE,ON)

# Form text color
form_text_color = (WHITE,CYAN,ON)

--- NEW FILE: form4 ---
#! /bin/sh
# $Id: form4,v 1.1 2006-10-23 20:59:30 stsp Exp $
# form3 with --item-help
: ${DIALOG=dialog}

backtitle="An Example for the use of --form:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --ok-label "Submit" \
	  --help-button \
	  --item-help \
	  --backtitle "$backtitle" \
	  --form "Here is a possible piece of a configuration program." \
20 50 0 \
	"Username:" 1 1	"$user" 1 10 10 0 "Login name" \
	"UID:"      2 1	"$uid"  2 10  8 0 "User ID" \
	"GID:"      3 1	"$gid"  3 10  8 0 "Group ID" \
	"HOME:"     4 1	"$home" 4 10 40 0 "User's home-directory" \
2>&1 1>&3`
returncode=$?
exec 3>&-

show=`echo "$value" |sed -e 's/^/	/'`

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Resulting data:\n\
$show" 10 40
		;;
	2)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" --no-collapse --cr-wrap \
		--msgbox "Help data:\n\
$show" 10 40
		;;
	*)
		echo "Return code was $returncode"
		exit
		;;
	esac
done

--- NEW FILE: checklist9 ---
#! /bin/sh
# $Id: checklist9,v 1.1 2006-10-23 20:59:29 stsp Exp $
# "checklist8" using --file
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --file checklist9.txt 2>$tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0|2)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: inputmenu ---
#! /bin/bash
# $Id: inputmenu,v 1.1 2006-10-23 20:59:31 stsp Exp $
# 2002 - written by Tobias Rittweiler <tobrit at freebits.de>
: ${DIALOG=dialog}

user="$USER"    ; uid="$UID"   ;
gid="$GROUPS"  ; home="$HOME"  ;

while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do
       exec 3>&1
       value=$("$DIALOG" --clear --ok-label "Create" \
                          --backtitle "An Example for the use of --inputmenu:" \
                          --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program. \
" 20 50 10 \
"Username:" "$user" \
"UID:"      "$uid" \
"GID:"      "$gid" \
"HOME:"     "$home" \
2>&1 1>&3 )
       returncode=$?
       exec 3>&-
       case $returncode in
       1)
               "$DIALOG"  --clear --backtitle "An Example for the use of --inputmenu:" \
                               --yesno "Really quit?" 10 30
               case $? in
                       0) break;;
                       1) returncode=99;;
               esac
               ;;
       0)
               "$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:"  \
			--msgbox "useradd \n\
				-d $home \n\
				-u $uid \n\
				-g $gid \n\
				$user" 10 40
               ;;
       3)
               value="${value:8:${#value}}"
               tag="${value%:*}"
               item="${value#*: }"

               case "$tag" in
                       Username) user="$item";;
                       UID) uid="$item";;
                       GID) gid="$item";;
                       HOME) home="$item";;
               esac
               ;;

       255)
                echo "ESC pressed."
                break
                ;;

       esac
done

--- NEW FILE: radiolist3 ---
#! /bin/sh
# $Id: radiolist3,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --item-help --ok-label Okay \
	--cancel-label 'Give Up' \
	--backtitle "No Such Organization" \
	--title "RADIOLIST BOX" --clear \
        --radiolist "Hi, this is a radiolist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"  "It's an apple." off "Hint: this grows in a tree" \
        "Dog"    "No, that's not my dog." ON "Hint: this likes trees" \
        "Orange" "Yeah, that's juicy." off "Hint: this is green when picked" \
        "Chicken"    "Normally not a pet." off "Hint: not often in trees" \
        "Cat"    "No, never put a dog and a cat together!" off "Hint: may be found in trees" \
        "Fish"   "Cats like fish." off "Hint: usually not close to cats" \
        "Lemon"  "You know how it tastes." off "Hint: like an orange" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: radiolist2 ---
#! /bin/sh
# $Id: radiolist2,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --ok-label Okay \
	--cancel-label 'Give Up' \
	--backtitle "No Such Organization" \
	--title "RADIOLIST BOX" --clear \
        --radiolist "Hi, this is a radiolist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"  "It's an apple." off \
        "Dog"    "No, that's not my dog." ON \
        "Orange" "Yeah, that's juicy." off \
        "Chicken"    "Normally not a pet." off \
        "Cat"    "No, never put a dog and a cat together!" off \
        "Fish"   "Cats like fish." off \
        "Lemon"  "You know how it tastes." off 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: radiolist4 ---
#! /bin/sh
# $Id: radiolist4,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button --help-label "Hints" --item-help --ok-label Okay \
	--cancel-label 'Give Up' \
	--backtitle "No Such Organization" \
	--title "RADIOLIST BOX" --clear \
        --radiolist "Hi, this is a radiolist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"  "It's an apple." off "Hint: this grows in a tree" \
        "Dog"    "No, that's not my dog." ON "Hint: this likes trees" \
        "Orange" "Yeah, that's juicy." off "Hint: this is green when picked" \
        "Chicken"    "Normally not a pet." off "Hint: not often in trees" \
        "Cat"    "No, never put a dog and a cat together!" off "Hint: may be found in trees" \
        "Fish"   "Cats like fish." off "Hint: usually not close to cats" \
        "Lemon"  "You know how it tastes." off "Hint: like an orange" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: checklist3 ---
#! /bin/sh
# $Id: checklist3,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --item-help --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an apple. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          off "fruit" \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "fruit" \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "not a fruit" \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  "not a fruit" \
        "Fish"       "Cats like fish. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                         On  "not a fruit" \
        "Lemon"      "You know how it tastes. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: timebox2-stdout ---
#!/bin/sh
# $Id: timebox2-stdout,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

USERTIME=`$DIALOG --stdout --title "TIMEBOX" --timebox "Please set the time..." 0 0`

case $? in
  0)
    echo "Time entered: $USERTIME.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: calendar-stdout ---
#!/bin/sh
# $Id: calendar-stdout,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

USERDATE=`$DIALOG --stdout --title "CALENDAR" --calendar "Please choose a date..." 0 0 7 7 1981`

case $? in
  0)
    echo "Date entered: $USERDATE.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "Box closed.";;
esac

--- NEW FILE: checklist9.txt ---
--help-button \
	--colors \
	--backtitle "\Z1No Such\Zn Organization" \
	--separate-output \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
\Z4UP/DOWN\Zn arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press \Zb\ZrSPACE\Zn to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an \Z1apple\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                    off \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off \
        ""           "No such pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            off \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  \
        "Fish"       "Cats like \Z4fish\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                   On  \
        "Lemon"      "You know how it \Zr\Zb\Z3tastes\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"     on

--- NEW FILE: checklist4 ---
#! /bin/sh
# $Id: checklist4,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button --item-help --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an apple. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          off "fruit" \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "fruit" \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "not a fruit" \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  "not a fruit" \
        "Fish"       "Cats like fish. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                         On  "not a fruit" \
        "Lemon"      "You know how it tastes. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: pause ---
#!/bin/sh
# $Id: pause,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "PAUSE" --pause "Hi, this is a pause widget" 20 70 10

retval=$?

case $retval in
  0)
    echo "Timeout expired.";;
  1)
    echo "Cancel pressed.";;
  *)
    echo "Unexpected return code: $retval";;
esac

--- NEW FILE: dialog.py ---
# $Id: dialog.py,v 1.1 2006-10-23 20:59:30 stsp Exp $
# Module: dialog.py
# Copyright (c) 2000 Robb Shecter <robb at acm.org>
# All rights reserved.
# This source is covered by the GNU GPL.
#
# This module is a Python wrapper around the Linux "dialog" utility
# by Savio Lam and Stuart Herbert.  My goals were to make dialog as
# easy to use from Python as possible.  The demo code at the end of
# the module is a good example of how to use it.  To run the demo,
# execute:
#
#                       python dialog.py
#
# This module has one class in it, "Dialog".  An application typically
# creates an instance of it, and possibly sets the background title option.
# Then, methods can be called on it for interacting with the user.
#
# I wrote this because I want to use my 486-33 laptop as my main
# development computer (!), and I wanted a way to nicely interact with the
# user in console mode.  There are apparently other modules out there
# with similar functionality, but they require the Python curses library.
# Writing this module from scratch was easier than figuring out how to
# recompile Python with curses enabled. :)
#
# One interesting feature is that the menu and selection windows allow
# *any* objects to be displayed and selected, not just strings.
#
# TO DO:
#   Add code so that the input buffer is flushed before a dialog box is
#     shown.  This would make the UI more predictable for users.  This
#     feature could be turned on and off through an instance method.
#   Drop using temporary files when interacting with 'dialog'
#     (it's possible -- I've already tried :-).
#   Try detecting the terminal window size in order to make reasonable
#     height and width defaults.  Hmmm - should also then check for 
#     terminal resizing...
#   Put into a package name to make more reusable - reduce the possibility
#     of name collisions.
#
# NOTES:
#         there is a bug in (at least) Linux-Mandrake 7.0 Russian Edition
#         running on AMD K6-2 3D that causes core dump when 'dialog' 
#         is running with --gauge option;
#         in this case you'll have to recompile 'dialog' program.
#
# Modifications:
# Jul 2000, Sultanbek Tezadov (http://sultan.da.ru)
#    Added:
#       - 'gauge' widget *)
#       - 'title' option to some widgets
#       - 'checked' option to checklist dialog; clicking "Cancel" is now
#           recognizable
#       - 'selected' option to radiolist dialog; clicking "Cancel" is now
#           recognizable
#       - some other cosmetic changes and improvements
#   

import os
from tempfile import mktemp
from string import split
from time import sleep

#
# Path of the dialog executable
#
DIALOG = os.getenv("DIALOG");
if DIALOG is None:
	DIALOG="../dialog";

class Dialog:
    def __init__(self):
	self.__bgTitle = ''               # Default is no background title


    def setBackgroundTitle(self, text):
	self.__bgTitle = '--backtitle "%s"' % text


    def __perform(self, cmd):
	"""Do the actual work of invoking dialog and getting the output."""
	fName = mktemp()
	rv = os.system('%s %s %s 2> %s' % (DIALOG, self.__bgTitle, cmd, fName))
	f = open(fName)
	output = f.readlines()
	f.close()
	os.unlink(fName)
	return (rv, output)


    def __perform_no_options(self, cmd):
	"""Call dialog w/out passing any more options. Needed by --clear."""
	return os.system(DIALOG + ' ' + cmd)


    def __handleTitle(self, title):
	if len(title) == 0:
	    return ''
	else:
	    return '--title "%s" ' % title


    def yesno(self, text, height=10, width=30, title=''):
	"""
	Put a Yes/No question to the user.
	Uses the dialog --yesno option.
	Returns a 1 or a 0.
	"""
	(code, output) = self.__perform(self.__handleTitle(title) +\
	    '--yesno "%s" %d %d' % (text, height, width))
	return code == 0


    def msgbox(self, text, height=10, width=30, title=''):
	"""
	Pop up a message to the user which has to be clicked
	away with "ok".
	"""
	self.__perform(self.__handleTitle(title) +\
	    '--msgbox "%s" %d %d' % (text, height, width))


    def infobox(self, text, height=10, width=30):
	"""Make a message to the user, and return immediately."""
	self.__perform('--infobox "%s" %d %d' % (text, height, width))


    def inputbox(self, text, height=10, width=30, init='', title=''):
	"""
	Request a line of input from the user.
	Returns the user's input or None if cancel was chosen.
	"""
	(c, o) = self.__perform(self.__handleTitle(title) +\
	    '--inputbox "%s" %d %d "%s"' % (text, height, width, init))
	try:
	    return o[0]
	except IndexError:
	    if c == 0:  # empty string entered
		return ''
	    else:  # canceled
		return None


    def textbox(self, filename, height=20, width=60, title=None):
	"""Display a file in a scrolling text box."""
	if title is None:
	    title = filename
	self.__perform(self.__handleTitle(title) +\
	    ' --textbox "%s" %d %d' % (filename, height, width))


    def menu(self, text, height=15, width=54, list=[]):
	"""
	Display a menu of options to the user.  This method simplifies the
	--menu option of dialog, which allows for complex arguments.  This
	method receives a simple list of objects, and each one is assigned
	a choice number.
	The selected object is returned, or None if the dialog was canceled.
	"""
	menuheight = height - 8
	pairs = map(lambda i, item: (i + 1, item), range(len(list)), list)
	choices = reduce(lambda res, pair: res + '%d "%s" ' % pair, pairs, '')
	(code, output) = self.__perform('--menu "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    return list[int(output[0]) - 1]
	except IndexError:
	    return None


    def checklist(self, text, height=15, width=54, list=[], checked=None):
	"""
	Returns a list of the selected objects.
	Returns an empty list if nothing was selected.
	Returns None if the window was canceled.
	checked -- a list of boolean (0/1) values; len(checked) must equal 
	    len(list).
	"""
	if checked is None:
	    checked = [0]*len(list)
	menuheight = height - 8
	triples = map(
	    lambda i, item, onoff, fs=('off', 'on'): (i + 1, item, fs[onoff]),
	    range(len(list)), list, checked)
	choices = reduce(lambda res, triple: res + '%d "%s" %s ' % triple,
	    triples, '')
	(c, o) = self.__perform('--checklist "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    output = o[0]
	    indexList  = map(lambda x: int(x[1:-1]), split(output))
	    objectList = filter(lambda item, list=list, indexList=indexList: 
		    list.index(item) + 1 in indexList,
		list)
	    return objectList
	except IndexError:
	    if c == 0:                        # Nothing was selected
		return []
	    return None  # Was canceled


    def radiolist(self, text, height=15, width=54, list=[], selected=0):
	"""
	Return the selected object.
	Returns empty string if no choice was selected.
	Returns None if window was canceled.
	selected -- the selected item (must be between 1 and len(list)
	    or 0, meaning no selection).
	"""
	menuheight = height - 8
	triples = map(lambda i, item: (i + 1, item, 'off'),
	    range(len(list)), list)
	if selected:
	    i, item, tmp = triples[selected - 1]
	    triples[selected - 1] = (i, item, 'on')
	choices = reduce(lambda res, triple: res + '%d "%s" %s ' % triple,
	    triples, '')
	(c, o) = self.__perform('--radiolist "%s" %d %d %d %s' %\
	    (text, height, width, menuheight, choices))
	try:
	    return list[int(o[0]) - 1]
	except IndexError:
	    if c == 0:
		return ''
	    return None
 

    def clear(self):
	"""
	Clear the screen. Equivalent to the dialog --clear option.
	"""
	self.__perform_no_options('--clear')


    def scrollbox(self, text, height=20, width=60, title=''):
	"""
	This is a bonus method.  The dialog package only has a function to
	display a file in a scrolling text field.  This method allows any
	string to be displayed by first saving it in a temp file, and calling
	--textbox.
	"""
	fName = mktemp()
	f = open(fName, 'w')
	f.write(text)
	f.close()
	self.__perform(self.__handleTitle(title) +\
	    '--textbox "%s" %d %d' % (fName, height, width))
	os.unlink(fName)


    def gauge_start(self, perc=0, text='', height=8, width=54, title=''):
	"""
	Display gauge output window.
	Gauge normal usage (assuming that there is an instace of 'Dialog'
	class named 'd'):
	    d.gauge_start()
	    # do something
	    d.gauge_iterate(10)  # passed throgh 10%
	    # ...
	    d.gauge_iterate(100, 'any text here')  # work is done
	    d.stop_gauge()  # clean-up actions
	"""
	cmd = self.__handleTitle(title) +\
	    '--gauge "%s" %d %d %d' % (text, height, width, perc)
	cmd = '%s %s %s 2> /dev/null' % (DIALOG, self.__bgTitle, cmd)
	self.pipe = os.popen(cmd, 'w')
    #/gauge_start()


    def gauge_iterate(self, perc, text=''):
	"""
	Update percentage point value.
	
	See gauge_start() function above for the usage.
	"""
	if text:
	    text = 'XXX\n%d\n%s\nXXX\n' % (perc, text)
	else:
	    text = '%d\n' % perc
	self.pipe.write(text)
	self.pipe.flush()
    #/gauge_iterate()
    
    
    def gauge_stop(self):
	"""
	Finish previously started gauge.
	
	See gauge_start() function above for the usage.
	"""
	self.pipe.close()
    #/gauge_stop()



#
# DEMO APPLICATION
#
if __name__ == '__main__':
    """
    This demo tests all the features of the class.
    """
    d = Dialog()
    d.setBackgroundTitle('dialog.py demo')

    d.infobox(
	"One moment... Just wasting some time here to test the infobox...")
    sleep(3)

    if d.yesno("Do you like this demo?"):
	d.msgbox("Excellent!  Here's the source code:")
    else:
	d.msgbox("Send your complaints to /dev/null")
    
    d.textbox("dialog.py")

    name = d.inputbox("What's your name?", init="Snow White")
    fday = d.menu("What's your favorite day of the week?", 
	list=["Monday", "Tuesday", "Wednesday", "Thursday", 
	    "Friday (The best day of all)", "Saturday", "Sunday"])
    food = d.checklist("What sandwich toppings do you like?", 
	list=["Catsup", "Mustard", "Pesto", "Mayonaise", "Horse radish", 
	    "Sun-dried tomatoes"], checked=[0,0,0,1,1,1])
    sand = d.radiolist("What's your favorite kind of sandwich?", 
	list=["Hamburger", "Hotdog", "Burrito", "Doener", "Falafel", 
	    "Bagel", "Big Mac", "Whopper", "Quarter Pounder", 
	    "Peanut Butter and Jelly", "Grilled cheese"], selected=4)

    # Prepare the message for the final window
    bigMessage = "Here are some vital statistics about you:\n\nName: " + name +\
        "\nFavorite day of the week: " + fday +\
	"\nFavorite sandwich toppings:\n"
    for topping in food:
	bigMessage = bigMessage + "    " + topping + "\n"
    bigMessage = bigMessage + "Favorite sandwich: " + str(sand)

    d.scrollbox(bigMessage)

    #<>#  Gauge Demo
    d.gauge_start(0, 'percentage: 0', title='Gauge Demo')
    for i in range(1, 101):
	if i < 50:
	    msg = 'percentage: %d' % i
	elif i == 50:
	    msg = 'Over 50%'
	else:
	    msg = ''
	d.gauge_iterate(i, msg)
	sleep(0.1)
    d.gauge_stop()
    #<>#

    d.clear()

--- NEW FILE: inputbox1 ---
#!/bin/sh
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --cr-wrap \
	--title "INPUT BOX" --clear \
        --inputbox \
"Hi, this is an input dialog box. You can use
this to ask questions that require the user
to input a string as the answer. You can 
input strings of length longer than the 
width of the input box, in that case, the 
input field will be automatically scrolled. 
You can use BACKSPACE to correct errors. 

Try entering your name below:" 0 0 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: inputmenu1 ---
#! /bin/sh
# $Id: inputmenu1,v 1.1 2006-10-23 20:59:31 stsp Exp $
#
# "inputmenu" rewritten into Bourne shell.
: ${DIALOG=dialog}

backtitle="An Example for the use of --inputmenu:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --clear --ok-label "Create" \
	  --backtitle "$backtitle" \
	  --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program." \
20 50 10 \
	"Username:"	"$user" \
	"UID:"		"$uid" \
	"GID:"		"$gid" \
	"HOME:"		"$home" \
2>&1 1>&3`
returncode=$?
exec 3>&-

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--msgbox "useradd \n\
			-d $home \n\
			-u $uid \n\
			-g $gid \n\
			$user" 10 40
		;;
	3)
		tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*//'`
		item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`

		case "$tag" in
		Username)
			user="$item"
			;;
		UID)
			uid="$item"
			;;
		GID)
			gid="$item"
			;;
		HOME)
			home="$item"
			;;
		esac
		;;

       255)
                echo "ESC pressed."
                break
                ;;

	esac
done

--- NEW FILE: checklist10 ---
#! /bin/sh
# $Id: checklist10,v 1.1 2006-10-23 20:59:29 stsp Exp $
# zero-width column
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG \
	--backtitle "No such organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
	Dialog		"" on \
	Readline	"" off \
	Gnome		"" off \
	Kde		"" off \
	Editor		"" off \
	Noninteractive	"" on \
        2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "'$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: inputmenu3 ---
#! /bin/sh
# $Id: inputmenu3,v 1.1 2006-10-23 20:59:31 stsp Exp $
#
# "inputmenu1" with defaultitem, help-button and item-help.
: ${DIALOG=dialog}

backtitle="An Example for the use of --inputmenu:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
defaultitem="Username:"
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --clear --ok-label "Create" \
	  --backtitle "$backtitle" \
	  --help-button \
	  --help-label "Script" \
	  --default-item "$defaultitem" \
	  --item-help \
	  --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program." \
20 60 10 \
	"Username:"	"$user" "User login-name" \
	"UID:"		"$uid"  "User-ID (number)" \
	"GID:"		"$gid"  "Group-ID (number)" \
	"HOME:"		"$home" "User's home-directory" \
2>&1 1>&3`
returncode=$?
exec 3>&-

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		case $value in
		HELP*)
			"$DIALOG" \
			--textbox "$0" 0 0
			;;
		*)
			"$DIALOG" \
			--clear \
			--backtitle "$backtitle" \
			--msgbox "useradd \n\
				-d $home \n\
				-u $uid \n\
				-g $gid \n\
				$user" 10 40
			;;
		esac
		;;
	2)
		"$DIALOG" \
		--textbox "$0" 0 0
		;;
	3)
		tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
		item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`

		case "$tag" in
		Username:)
			user="$item"
			;;
		UID:)
			uid="$item"
			;;
		GID:)
			gid="$item"
			;;
		HOME:)
			home="$item"
			;;
		*)
			tag=
			;;
		esac
		test -n "$tag" && defaultitem="$tag"
		;;

        255)
                echo "ESC pressed."
                break
                ;;

	esac
done

--- NEW FILE: inputmenu2 ---
#! /bin/sh
# $Id: inputmenu2,v 1.1 2006-10-23 20:59:31 stsp Exp $
#
# "inputmenu1" with defaultitem, help-button.
: ${DIALOG=dialog}

backtitle="An Example for the use of --inputmenu:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
defaultitem="Username:"
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --clear --ok-label "Create" \
	  --backtitle "$backtitle" \
	  --help-button \
	  --help-label "Script" \
	  --default-item "$defaultitem" \
	  --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program." \
20 60 10 \
	"Username:"	"$user" \
	"UID:"		"$uid"  \
	"GID:"		"$gid"  \
	"HOME:"		"$home" \
2>&1 1>&3`
returncode=$?
exec 3>&-

	case $returncode in
	2)
		"$DIALOG" \
		--textbox "$0" 0 0
		;;
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--msgbox "useradd \n\
			-d $home \n\
			-u $uid \n\
			-g $gid \n\
			$user" 10 40
		;;
	3)
		tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*/:/'`
		item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`

		case "$tag" in
		Username:)
			user="$item"
			;;
		UID:)
			uid="$item"
			;;
		GID:)
			gid="$item"
			;;
		HOME:)
			home="$item"
			;;
		*)
			tag=
			;;
		esac
		test -n "$tag" && defaultitem="$tag"
		;;

       255)
                echo "ESC pressed."
                break
                ;;

	esac
done

--- NEW FILE: inputmenu4 ---
#! /bin/sh
# $Id: inputmenu4,v 1.1 2006-10-23 20:59:31 stsp Exp $
#
# "inputmenu1" with a different label for the extra-button
: ${DIALOG=dialog}

backtitle="An Example for the use of --inputmenu:"

ids=`id|sed -e 's/([^)]*)//g'`
uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'`
gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'`

user="$USER"
home="$HOME"

returncode=0
while test $returncode != 1 && test $returncode != 250
do
exec 3>&1
value=`$DIALOG --clear --ok-label "Create" \
	--extra-label "Edit" \
	  --backtitle "$backtitle" \
	  --inputmenu "Originally I designed --inputmenu for a \
configuration purpose. Here is a possible piece of a configuration program." \
20 50 10 \
	"Username:"	"$user" \
	"UID:"		"$uid" \
	"GID:"		"$gid" \
	"HOME:"		"$home" \
2>&1 1>&3`
returncode=$?
exec 3>&-

	case $returncode in
	1)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--yesno "Really quit?" 10 30
		case $? in
		0)
			break
			;;
		1)
			returncode=99
			;;
		esac
		;;
	0)
		"$DIALOG" \
		--clear \
		--backtitle "$backtitle" \
		--msgbox "useradd \n\
			-d $home \n\
			-u $uid \n\
			-g $gid \n\
			$user" 10 40
		;;
	3)
		tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*//'`
		item=`echo "$value" |sed -e 's/^.*:[ ]*//' -e 's/[ ]*$//'`

		case "$tag" in
		Username)
			user="$item"
			;;
		UID)
			uid="$item"
			;;
		GID)
			gid="$item"
			;;
		HOME)
			home="$item"
			;;
		esac
		;;

        255)
                echo "ESC pressed."
                break
                ;;

	esac
done

--- NEW FILE: msgbox4-8bit ---
#!/bin/sh
# $Id: msgbox4-8bit,v 1.1 2006-10-23 20:59:32 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

. ./testdata-8bit

width=30
while test $width != 61
do
$DIALOG --title "MESSAGE BOX (width $width)" --no-collapse --colors \
        --msgbox "\
This sample uses characters which are non-printing in POSIX locale.

\Z1`./rotated-data 0 $SAMPLE` \Z2`./rotated-data 1 $SAMPLE` \Z3`./rotated-data 2 $SAMPLE` \Z4`./rotated-data 3 $SAMPLE`\Zn

Hi, this is a simple message box.  You can use this to \
display any message you like.  The box will remain until \
you press the ENTER key." 22 $width
retval=$?

case $retval in
  $DIALOG_CANCEL)
    echo "Cancel pressed.";exit;;
  $DIALOG_ESC)
    echo "ESC pressed.";exit;;
esac

width=`expr $width + 1`

done

--- NEW FILE: inputbox ---
#!/bin/sh
# $Id: inputbox,v 1.1 2006-10-23 20:59:30 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --title "INPUT BOX" --clear \
        --inputbox "Hi, this is an input dialog box. You can use \n
this to ask questions that require the user \n
to input a string as the answer. You can \n
input strings of length longer than the \n
width of the input box, in that case, the \n
input field will be automatically scrolled. \n
You can use BACKSPACE to correct errors. \n\n
Try entering your name below:" 16 51 2> $tempfile

retval=$?

case $retval in
  0)
    echo "Input string is `cat $tempfile`";;
  1)
    echo "Cancel pressed.";;
  255)
    if test -s $tempfile ; then
      cat $tempfile
    else
      echo "ESC pressed."
    fi
    ;;
esac

--- NEW FILE: checklist2 ---
#! /bin/sh
# $Id: checklist2,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --item-help --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an apple."                          off "fruit" \
        "Dog"        "No, that's not my dog."                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy."                     off "fruit" \
        "Chicken"    "Normally not a pet."                     off "not a fruit" \
        "Cat"        "No, never put a dog and a cat together!" oN  "not a fruit" \
        "Fish"       "Cats like fish."                         On  "not a fruit" \
        "Lemon"      "You know how it tastes."                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: testdata-8bit ---
#!/bin/sh
# $Id: testdata-8bit,v 1.1 2006-10-23 20:59:32 stsp Exp $

# Select one of the "SAMPLE=" lines, to test handling of characters which
# are nonprinting in a POSIX locale:

case .$1 in
	# C1 controls
.8)
	SAMPLE="€‚ƒ„…†‡ˆ‰Š‹ŒŽ"
	;;
.9)
	SAMPLE="‘’“”•–—˜™š›œžŸ"
	;;

# Latin-1
.[aA])
	SAMPLE=" ¡¢£¤¥¦§¨©ª«¬­®¯"
	;;
.[bB])
	SAMPLE="°±²³´µ¶·¸¹º»¼½¾¿"
	;;
.[cC])
	SAMPLE="ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ"
	;;
.[dD])
	SAMPLE="ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß"
	;;
.[eE])
	SAMPLE="àáâãäåæçèéêëìíîï"
	;;
.[fF])
	SAMPLE="ðñòóôõö÷øùúûüýþÿ"
	;;
*)
	# C0 controls (except a few which are always treated specially by curses):
	SAMPLE=""
	;;
esac

--- NEW FILE: checklist1 ---
#! /bin/sh
# $Id: checklist1,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

: ${DIALOG_OK=0}
: ${DIALOG_CANCEL=1}
: ${DIALOG_ESC=255}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "" "It's an apple." off \
        "Dog"    "No, that's not my dog." ON \
        "Orange" "Yeah, that's juicy." off \
        "Chicken"    "" off \
        "Cat"    "No, never put a dog and a cat together!" oN \
        "Fish"   "Cats like fish." On \
        "Lemon"  "You know how it tastes." on 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  $DIALOG_OK)
    echo "'$choice' chosen.";;
  $DIALOG_CANCEL)
    echo "Cancel pressed.";;
  $DIALOG_ESC)
    echo "ESC pressed.";;
  *)
    echo "Unexpected return code: $retval (ok would be $DIALOG_OK)";;
esac

--- NEW FILE: checklist6 ---
#! /bin/sh
# $Id: checklist6,v 1.1 2006-10-23 20:59:29 stsp Exp $
# example showing the --colors option
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button --item-help --colors --backtitle "\Z1No Such\Zn Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
\Z4UP/DOWN\Zn arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press \Zb\ZrSPACE\Zn to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an \Z1apple\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          off "fruit" \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "fruit" \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "not a fruit" \
        ""           "No such pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            off "not anything" \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  "not a fruit" \
        "Fish"       "Cats like \Z4fish\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                         On  "not a fruit" \
        "Lemon"      "You know how it \Zr\Zb\Z3tastes\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: checklist7 ---
#! /bin/sh
# $Id: checklist7,v 1.1 2006-10-23 20:59:29 stsp Exp $
# "checklist6" with --separate-output
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button \
	--item-help \
	--colors \
	--backtitle "\Z1No Such\Zn Organization" \
	--separate-output \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
\Z4UP/DOWN\Zn arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press \Zb\ZrSPACE\Zn to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an \Z1apple\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          off "fruit" \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "fruit" \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "not a fruit" \
        ""           "No such pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            off "not anything" \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  "not a fruit" \
        "Fish"       "Cats like \Z4fish\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                         On  "not a fruit" \
        "Lemon"      "You know how it \Zr\Zb\Z3tastes\Zn. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac

--- NEW FILE: yesno-both ---
#!/bin/sh
# $Id: yesno-both,v 1.1 2006-10-23 20:59:33 stsp Exp $
: ${DIALOG=dialog}

$DIALOG --title "YES/NO/MAYBE BOX" \
	--clear \
	--ok-label "Next" \
	--no-label "Cancel" \
	--extra-label "Previous" --extra-button \
	--help-button \
        --yesno "Hi, this is a yes/no dialog box with its labels changed. \
                 You can use this to ask \
                 questions that have an answer of either yes or no (or maybe). \
                 BTW, do you notice that long lines will be automatically \
                 wrapped around so that they can fit in the box? You can \
                 also control line breaking explicitly by inserting \
                 'backslash n' at any place you like, but in this case, \
                 auto wrap around will be disabled and you will have to \
                 control line breaking yourself." 15 61

case $? in
  0)
    echo "Next chosen.";;
  1)
    echo "Cancel chosen.";;
  2)
    echo "Help pressed.";;
  3)
    echo "Previous pressed.";;
  255)
    echo "ESC pressed.";;
esac

--- NEW FILE: checklist5 ---
#! /bin/sh
# $Id: checklist5,v 1.1 2006-10-23 20:59:29 stsp Exp $
: ${DIALOG=dialog}

tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --help-button --item-help --backtitle "No Such Organization" \
	--title "CHECKLIST BOX" \
        --checklist "Hi, this is a checklist box. You can use this to \n\
present a list of choices which can be turned on or \n\
off. If there are more items than can fit on the \n\
screen, the list will be scrolled. You can use the \n\
UP/DOWN arrow keys, the first letter of the choice as a \n\
hot key, or the number keys 1-9 to choose an option. \n\
Press SPACE to toggle an option on/off. \n\n\
  Which of the following are fruits?" 20 61 5 \
        "Apple"      "It's an apple. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                          off "fruit" \
        "Dog"        "No, that's not my dog. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                  ON  "not a fruit" \
        "Orange"     "Yeah, that's juicy. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "fruit" \
        "Chicken"    "Normally not a pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                     off "not a fruit" \
        ""           "No such pet. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                            off "not anything" \
        "Cat"        "No, never put a dog and a cat together! xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" oN  "not a fruit" \
        "Fish"       "Cats like fish. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                         On  "not a fruit" \
        "Lemon"      "You know how it tastes. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"                 on  "the only one you wouldn't eat" 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
  0)
    echo "OK '$choice' chosen.";;
  1)
    echo "Cancel pressed.";;
  2)
    echo "HELP '$choice' chosen.";;
  255)
    echo "ESC pressed.";;
  *)
    echo "Unexpected code $retval";;
esac




More information about the dslinux-commit mailing list