Username: Save?
Password:
Home Forum Links Search Login Register*
    News: Welcome to the TechnoWorldInc! Community!
Recent Updates
[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 24, 2024, 11:48:22 AM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[April 03, 2024, 06:11:00 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[March 06, 2024, 02:45:27 PM]

[February 14, 2024, 02:00:39 PM]
Subscriptions
Get Latest Tech Updates For Free!
Resources
   Travelikers
   Funistan
   PrettyGalz
   Techlap
   FreeThemes
   Videsta
   Glamistan
   BachatMela
   GlamGalz
   Techzug
   Vidsage
   Funzug
   WorldHostInc
   Funfani
   FilmyMama
   Uploaded.Tech
   MegaPixelShop
   Netens
   Funotic
   FreeJobsInc
   FilesPark
Participate in the fastest growing Technical Encyclopedia! This website is 100% Free. Please register or login using the login box above if you have already registered. You will need to be logged in to reply, make new topics and to access all the areas. Registration is free! Click Here To Register.
+ Techno World Inc - The Best Technical Encyclopedia Online! » Forum » THE TECHNO CLUB [ TECHNOWORLDINC.COM ] » Programming Zone » Shell Script
 Simple Menu for User Input
Pages: [1]   Go Down
  Print  
Author Topic: Simple Menu for User Input  (Read 3149 times)
Mark David
Administrator
Super Elite Member
*****



Karma: 185
Offline Offline

Posts: 1624

!!!Techno King!!!

fabulous_designer
View Profile WWW
Simple Menu for User Input
« Posted: March 16, 2007, 12:54:16 PM »


Simple Menu for User Input

This script will create an input screen in BASH that allows the user to enter information just as they would in a window. This is to show the use of simple functions as well as the tput command. "tput cup" allows the developer to place the cursor anywhere on the screen. There are many more commands that tput recognizes, see the man page for more information.

Code:
#!/bin/bash 

## Clears the screen and builds the user input screen

function screen() {
clear
cat <<EOF
####################################################################
##                 Main Screen for Input                          ##
####################################################################
##                                                                ##
##   User Name:   _________________________________________       ##
##   Directory:   _________________________________________       ##
##   Group:       _________________________________________       ##
##                                                                ##
####################################################################
## Preferences                 ##      Other Info                 ##
####################################################################
##  Show Email?    _           ##      Receive News?  _           ##
##  Show Address?  _           ##      Receive RSS?   _           ##
####################################################################
EOF
}

## This will echo out the contents of the helpString variable
## below the screen
function showHelp() {
tput cup 14 0
## Clear out the last information
echo "                                                                            "
tput cup 14 0
echo $helpString
}
## Display the screen
screen

## Set up the help information, and call the showHelp function
## that displays it
helpString="Enter the user or press ENTER to quit"
showHelp
tput cup 4 18
read username
## If they don't enter a username, quit
if [ "$username" = "" ]
then
  exit
fi

## Now go through and get the other data
helpString="Enter Home Directory"
showHelp
tput cup 5 18
read directory

helpString="What group does $username belong to?"
showHelp
tput cup 6 18
read group

helpString="Do you want to show the Email Address to others? [y/n"
showHelp
tput cup 11 19
read showEmail

helpString="Do you want to show your Home Address to others [y/n]"
showHelp
tput cup 12 19
read showAddress

helpString="Would you like to receive the News Letter?"
showHelp
tput cup 11 54
read getNews

helpString="Would you like to receive the RSS Feed?"
showHelp
tput cup 12 54
read getRSS

helpString="Thank you for your input"
showHelp
echo ""

Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Copyright © 2006-2023 TechnoWorldInc.com. All Rights Reserved. Privacy Policy | Disclaimer
Page created in 0.125 seconds with 24 queries.