1#! /bin/sh 2# $Id: inputmenu3,v 1.11 2012/07/01 01:00:34 tom Exp $ 3# 4# "inputmenu1" with defaultitem, help-button and item-help. 5 6. ./setup-vars 7 8backtitle="An Example for the use of --inputmenu:" 9 10ids=`id|sed -e 's/([^)]*)//g'` 11uid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'` 12gid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'` 13 14user="$USER" 15home="$HOME" 16 17returncode=0 18defaultitem="Username:" 19while test $returncode != 1 && test $returncode != 250 20do 21exec 3>&1 22value=`$DIALOG --clear --ok-label "Create" \ 23 --backtitle "$backtitle" \ 24 --help-button \ 25 --help-label "Script" \ 26 --default-item "$defaultitem" \ 27 --item-help "$@" \ 28 --inputmenu "Originally I designed --inputmenu for a \ 29configuration purpose. Here is a possible piece of a configuration program." \ 3020 60 10 \ 31 "Username:" "$user" "User login-name" \ 32 "UID:" "$uid" "User-ID (number)" \ 33 "GID:" "$gid" "Group-ID (number)" \ 34 "HOME:" "$home" "User's home-directory" \ 352>&1 1>&3` 36returncode=$? 37exec 3>&- 38 39 case $returncode in 40 $DIALOG_CANCEL) 41 "$DIALOG" \ 42 --clear \ 43 --backtitle "$backtitle" \ 44 --yesno "Really quit?" 10 30 45 case $? in 46 $DIALOG_OK) 47 break 48 ;; 49 $DIALOG_CANCEL) 50 returncode=99 51 ;; 52 esac 53 ;; 54 $DIALOG_OK) 55 case $value in 56 HELP*) 57 "$DIALOG" \ 58 --textbox "$0" 0 0 59 ;; 60 *) 61 "$DIALOG" \ 62 --clear \ 63 --backtitle "$backtitle" \ 64 --msgbox "useradd \n\ 65 -d $home \n\ 66 -u $uid \n\ 67 -g $gid \n\ 68 $user" 10 40 69 ;; 70 esac 71 ;; 72 $DIALOG_HELP) 73 "$DIALOG" \ 74 --textbox "$0" 0 0 75 ;; 76 $DIALOG_EXTRA) 77 tag=`echo "$value" |sed -e 's/^RENAMED //' -e 's/:.*/:/'` 78 item=`echo "$value" |sed -e 's/^[^:]*:[ ]*//' -e 's/[ ]*$//'` 79 80 case "$tag" in 81 Username:) 82 user="$item" 83 ;; 84 UID:) 85 uid="$item" 86 ;; 87 GID:) 88 gid="$item" 89 ;; 90 HOME:) 91 home="$item" 92 ;; 93 *) 94 tag= 95 ;; 96 esac 97 test -n "$tag" && defaultitem="$tag" 98 ;; 99 100 $DIALOG_ESC) 101 echo "ESC pressed." 102 break 103 ;; 104 105 esac 106done 107