1#! /bin/bash 2# $Id: inputmenu-stdout,v 1.8 2010/01/13 10:30:14 tom Exp $ 3# 2002 - written by Tobias Rittweiler <tobrit@freebits.de> 4 5. ./setup-vars 6 7user="$USER" ; uid="$UID" ; 8gid="$GROUPS" ; home="$HOME" ; 9 10while [ ${returncode:-99} -ne 1 -a ${returncode:-99} -ne 250 ]; do 11 value="$("$DIALOG" --stdout --clear --ok-label "Create" \ 12 --backtitle "An Example for the use of --inputmenu:" "$@" \ 13 --inputmenu "Originally I designed --inputmenu for a \ 14configuration purpose. Here is a possible piece of a configuration program. 15" 20 50 10 "Username:" "$user" "UID:" "$uid" "GID:" "$gid" "HOME:" "$home")" 16 returncode=$? 17 case $returncode in 18 $DIALOG_CANCEL) 19 "$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \ 20 --yesno "Really quit?" 10 30 21 case $? in 22 $DIALOG_OK) break;; 23 $DIALOG_CANCEL) returncode=99;; 24 esac 25 ;; 26 $DIALOG_OK) 27 "$DIALOG" --clear --backtitle "An Example for the use of --inputmenu:" \ 28 --msgbox "useradd \n\ 29 -d $home \n\ 30 -u $uid \n\ 31 -g $gid \n\ 32 $user" 10 40 33 ;; 34 $DIALOG_EXTRA) 35 value="${value:8:${#value}}" 36 tag="${value%:*}" 37 item="${value#*: }" 38 39 case "$tag" in 40 Username) user="$item";; 41 UID) uid="$item";; 42 GID) gid="$item";; 43 HOME) home="$item";; 44 esac 45 ;; 46 47 $DIALOG_ESC) 48 echo "ESC pressed." 49 break 50 ;; 51 52 esac 53done 54