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