Sponsored Content
Top Forums Shell Programming and Scripting help with scripting a simple menu Post 302323240 by Jsmith on Saturday 6th of June 2009 01:52:35 AM
Old 06-06-2009
help with scripting a simple menu

Hi there. I'm trying to teach myself UNIX but the book I bought is a bit confusing. I'm trying out this exercise and I think I'm on the right track, but I'd appreciate any suggestions on how to improve what I have so far. Also, I'm not clear on how to use the read command to utilize the user's input (#'s 4-7). I appreciate your help!

Code:
 
#!/bin/bash
while:
do
clear
# Display menu
echo
echo  "*************************************************************"    
echo  "Please choose from the following options; type the" 
echo  "option number and hit the <Enter> key."
echo
echo  "   1) To list names of the files in the current DIR"
echo  "   2) Display today's date and time"
echo  "   3) Display a sorted list of people currently logged on"
echo  "   4) Display whether a file is a file or a DIR"
echo  "   5) Create a backup for a file"
echo  "   6) Find a user by First of Last name in /etc/passwd file"
echo  "   7) Find the manual pages for a specific command"
echo  "   8) Exit"
echo
echo  "*************************************************************"  
 
read option
 
case "$option" in 
    1)    echo "The files in the current DIR are: " 
          ls -l 
          echo "Hit <Enter> to continue." 
          read ignore 
          ;; 
 
    2)    echo "The current date is: " 
          date 
          unset date 
          echo "Hit <Enter> to continue." 
          read ignore 
          ;; 
 
    3)    echo "The following is a list of the academic scholars" 
          echo "currently logged in:" 
          who | cut -d " " -f1 | sort     
          echo "Hit <Enter> to continue." 
          read ignore 
          ;; 
 
    4)    echo "Enter file to determine whether a "simple" file or a" 
          echo "directory:" 
 
    5)    echo "Enter the file you would like to create a backup for:" 
 
 
    6)    echo "Enter user's first or last name:" 
 
 
    7)    echo "Enter command for which you would like the manual:" 
 
 
    8)    echo "Thank You for using Skynet" 
          echo "Remember: Skynet is the Future" 
          sleep 1.5 
          clear 
          exit 0 
          ;; 
 
    *)   echo "Invalid option; try running the program again." 
         exit 1 
         ;;    
 
esac
 
done.
 
exit 0

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

scripting for menu

Hi, I'm writting a script to filter a cvs log and get only the modified files to move them to a specific directory to compile. I try to filter a line and move from source to target, with no results. Could you help me? for example, in the cvs log file appears: cat log.txt U... (2 Replies)
Discussion started by: Manu
2 Replies

2. Shell Programming and Scripting

Simple Menu and coding

I am very new to Unix and don't know much about it. I've been trying to create a menu and what I don't understand is how to execute a command once a user makes a selection. I have the menu set up. In fact, the following is the code that I have thus far: #! /bin/csh # This is the UNIX menu... (0 Replies)
Discussion started by: sinjin
0 Replies

3. Shell Programming and Scripting

Scripting problem - when the file is not found i want it to return to the menu

when the file is not found i want it to return to the menu, however it carries out the next line when i hit a key I know its probably something simple can anyone help? here is my pause function: function pause(){ read -s -n 1 -p "Press any key to return to Menu . . ." echo } SCRIPT... (2 Replies)
Discussion started by: Alendrin
2 Replies

4. UNIX for Dummies Questions & Answers

Scripting menu problem

Hi there, I am new to Unix and at the moment I am trying to solve my assignment that is to create a script for the program to prompt user to type three codes, from user point of view it should be done by typing codes separating them by spaces. Then program displays a menu with these three... (5 Replies)
Discussion started by: Dannel
5 Replies

5. Shell Programming and Scripting

Perl simple text menu with options

Hopefully I'm in the right place. Im new to the forums and linux! I'm looking to add a menu to my perl hangman game i have created. The menu will use user input for the desired option and then perform the operation indicated. I would like something along the lines of: Welcome to Hangman... (1 Reply)
Discussion started by: jahburmski
1 Replies

6. Shell Programming and Scripting

Two columns output in simple case menu?

EDIT : System used : Any Linux distribution. Hello everyone, I m having quite a headache trying to figure out why I m having a 2 columns output in the following code : #!/bin/ksh menu_rotation() { #Variables CHOIX1="Rotation 1" CHOIX2="Rotation 2" CHOIX3="Rotation 3" ... (11 Replies)
Discussion started by: Sekullos
11 Replies

7. UNIX for Dummies Questions & Answers

Simple bash script menu

Dear Sir, May I know how do I go about adding the following feature into the script below: When user enter values other than 1,2,3,4, a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed b) The screen is cleared again and the menu is displayed. #!/bin/bash clear var=1... (2 Replies)
Discussion started by: fusetrips
2 Replies

8. Shell Programming and Scripting

Simple calculator with menu input - Need Help

I am trying to make a calculator. The user Enters number 1, chooses and operation, enters number 2, then chooses another operation or for the answer to be displayed. eg. 1 + 1 = or 1 + 1 + 2 + 1 = Both of these should be possible. #!/bin/bash read -p "what's the first number? " n1... (3 Replies)
Discussion started by: redshine6
3 Replies

9. Homework & Coursework Questions

Shell scripting/menu

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Write a shell menu program that will: a. copy a file to a designated directory b. tell you if a specified user... (13 Replies)
Discussion started by: Jagst3r21
13 Replies

10. Shell Programming and Scripting

Menu and case statement scripting

hi all i am trying to get help with writing a script using case statement to display menu as 1) Authentication log 2) System log 3) Messages 4) Dmesg 5) Boot log Q) Exit When selecting the menu by 1 or 2 or 3 o 4 or 5, it should display the last 10 lines of the log files, if... (3 Replies)
Discussion started by: renegade11
3 Replies
DH_INSTALLMENU(1)						     Debhelper							 DH_INSTALLMENU(1)

NAME
dh_installmenu - install Debian menu files into package build directories SYNOPSIS
dh_installmenu [debhelperoptions] [-n] DESCRIPTION
dh_installmenu is a debhelper program that is responsible for installing files used by the Debian menu package into package build directories. It also automatically generates the postinst and postrm commands needed to interface with the Debian menu package. These commands are inserted into the maintainer scripts by dh_installdeb(1). FILES
debian/package.menu Debian menu files, installed into usr/share/menu/package in the package build directory. See menufile(5) for its format. debian/package.menu-method Debian menu method files, installed into etc/menu-methods/package in the package build directory. OPTIONS
-n, --no-scripts Do not modify postinst/postrm scripts. SEE ALSO
debhelper(7) update-menus(1) menufile(5) This program is a part of debhelper. AUTHOR
Joey Hess <joeyh@debian.org> 11.1.6ubuntu2 2018-05-10 DH_INSTALLMENU(1)
All times are GMT -4. The time now is 10:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy