The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scripting problem - when the file is not found i want it to return to the menu Alendrin Shell Programming and Scripting 2 03-04-2009 01:25 PM
Simple Menu and coding sinjin Shell Programming and Scripting 0 12-11-2007 08:42 AM
HELP me PLS... Simple Scripting! liezer Shell Programming and Scripting 2 09-14-2006 10:50 AM
simple scripting question gennaro Shell Programming and Scripting 3 06-17-2005 03:49 AM
scripting for menu Manu Shell Programming and Scripting 2 05-02-2005 03:17 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-06-2009
Jsmith Jsmith is offline
Registered User
  
 

Join Date: May 2009
Posts: 3
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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0