1217309Snwhitehorn#! /bin/sh 2251843Sbapt# $Id: form1,v 1.15 2011/10/04 23:36:53 tom Exp $ 3217309Snwhitehorn 4217309Snwhitehorn. ./setup-vars 5217309Snwhitehorn 6217309SnwhitehornDIALOG_ERROR=254 7217309Snwhitehornexport DIALOG_ERROR 8217309Snwhitehorn 9217309Snwhitehornbacktitle="An Example for the use of --form:" 10217309Snwhitehorn 11217309Snwhitehornids=`id|sed -e 's/([^)]*)//g'` 12217309Snwhitehornuid=`echo "$ids" | sed -e 's/^uid=//' -e 's/ .*//'` 13217309Snwhitehorngid=`echo "$ids" | sed -e 's/^.* gid=//' -e 's/ .*//'` 14217309Snwhitehorn 15217309Snwhitehornuser="$USER" 16217309Snwhitehornhome="$HOME" 17217309Snwhitehorn 18217309Snwhitehornreturncode=0 19217309Snwhitehornwhile test $returncode != 1 && test $returncode != 250 20217309Snwhitehorndo 21217309Snwhitehornexec 3>&1 22217309Snwhitehornvalue=`$DIALOG --ok-label "Submit" \ 23217309Snwhitehorn --backtitle "$backtitle" "$@" \ 24217309Snwhitehorn --form "Here is a possible piece of a configuration program." \ 25217309Snwhitehorn20 50 0 \ 26217309Snwhitehorn "Username:" 1 1 "$user" 1 10 10 0 \ 27217309Snwhitehorn "UID:" 2 1 "$uid" 2 10 8 0 \ 28217309Snwhitehorn "GID:" 3 1 "$gid" 3 10 8 0 \ 29217309Snwhitehorn "HOME:" 4 1 "$home" 4 10 40 0 \ 30217309Snwhitehorn2>&1 1>&3` 31217309Snwhitehornreturncode=$? 32217309Snwhitehornexec 3>&- 33217309Snwhitehorn 34217309Snwhitehornshow=`echo "$value" |sed -e 's/^/ /'` 35217309Snwhitehorn 36217309Snwhitehorn case $returncode in 37217309Snwhitehorn $DIALOG_CANCEL) 38217309Snwhitehorn "$DIALOG" \ 39217309Snwhitehorn --clear \ 40217309Snwhitehorn --backtitle "$backtitle" \ 41217309Snwhitehorn --yesno "Really quit?" 10 30 42217309Snwhitehorn case $? in 43217309Snwhitehorn $DIALOG_OK) 44217309Snwhitehorn break 45217309Snwhitehorn ;; 46217309Snwhitehorn $DIALOG_CANCEL) 47217309Snwhitehorn returncode=99 48217309Snwhitehorn ;; 49217309Snwhitehorn esac 50217309Snwhitehorn ;; 51217309Snwhitehorn $DIALOG_OK) 52217309Snwhitehorn "$DIALOG" \ 53217309Snwhitehorn --clear \ 54217309Snwhitehorn --backtitle "$backtitle" --no-collapse --cr-wrap \ 55217309Snwhitehorn --msgbox "Resulting data:\n\ 56217309Snwhitehorn$show" 10 40 57217309Snwhitehorn ;; 58217309Snwhitehorn $DIALOG_HELP) 59217309Snwhitehorn echo "Button 2 (Help) pressed." 60217309Snwhitehorn exit 61217309Snwhitehorn ;; 62217309Snwhitehorn $DIALOG_EXTRA) 63217309Snwhitehorn echo "Button 3 (Extra) pressed." 64217309Snwhitehorn exit 65217309Snwhitehorn ;; 66251843Sbapt $DIALOG_ERROR) 67251843Sbapt echo "ERROR!$value" 68217309Snwhitehorn exit 69217309Snwhitehorn ;; 70217309Snwhitehorn $DIALOG_ESC) 71217309Snwhitehorn echo "ESC pressed." 72217309Snwhitehorn exit 73217309Snwhitehorn ;; 74217309Snwhitehorn *) 75217309Snwhitehorn echo "Return code was $returncode" 76217309Snwhitehorn exit 77217309Snwhitehorn ;; 78217309Snwhitehorn esac 79217309Snwhitehorndone 80