Sponsored Content
Full Discussion: Shell scripting/menu
Homework and Emergencies Homework & Coursework Questions Shell scripting/menu Post 302802571 by Jagst3r21 on Friday 3rd of May 2013 10:55:48 PM
Old 05-03-2013
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 is logged in.
c. display the details of a specified file
d. list the contents of a specified directory

Check for input errors, issues an error message and continue until the exit option is chosen.

2. Relevant commands, code, scripts, algorithms:

Shell scripting

3. The attempts at a solution (include all code and scripts):

Code:
# Use of a case statement to offer a 5 item menu
echo “  Menu\n
1. Copy a file to a designated directory\n
2. Check whether a specified user is logged in\n
3. Display the details of a specified file\n
4. List the contents of a specified directory\n
5. Quit to Unix\nEnter your option #: \c”
read choice
case “$choice” in
1)	cp file $HOME
2)	who | grep 'name'
3)      ls -l file
4)      ls directory
5)      exit ;;
*)	echo “Invalid option”   # ;; not needed for last option
esac

A couple things:

1) Is this a step in the right direction? And could someone please test it just to see if it functions?

2) How would I make the program more portable so that the user can enter the name of a file for option one or enter the name of the person for option 2. What I mean is, how do you make it so you have variables for the options instead of hardcoded ones?

I need to also turn in a printout of the program listing or something too, whatever that means(?)

Thanks.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Brookdale Community College - Lincroft, New Jersey - United States - Dr. Rick Bournique- COMP 145


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by vbe; 05-04-2013 at 11:01 AM..
 

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

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 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. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: Jsmith
3 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. 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

7. Shell Programming and Scripting

Shell script menu

hi guys, how would you do the following? I have a menu with 5 options in my shell script: 1. Run function 1 against files 2. Run function 2 against files 3. Run function 3 against files 4. Run function 4 against files 5. Run function 5 against files I'd like to be able to run multiple... (10 Replies)
Discussion started by: rich@ardz
10 Replies

8. Shell Programming and Scripting

Menu using shell script

Hi, I need to have a shell script for the below need. 1. Menu with one heading and 4 options. 2. the heading and 4 options are taken from a file. File entry ====== Heading1|option1|option2|option3|option4| Heading2|option1|option2|option3|option4| 3. the user entries must be captured in... (9 Replies)
Discussion started by: umastinu
9 Replies

9. Shell Programming and Scripting

Menu shell script help

Hi All, I have written a shell script that show menu driven option. My requirement is that in the menu driven option i want to select multiple choice. i.e if i want to select 1 or 1,2 or 1,2,3 or 2,3 etc .... Can some one help me in that My script. while true; do echo " " ... (8 Replies)
Discussion started by: Nawrajesh
8 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
tk_menuBar(1T)						       Tk Built-In Commands						    tk_menuBar(1T)

__________________________________________________________________________________________________________________________________________________

NAME
tk_menuBar, tk_bindForTraversal - Obsolete support for menu bars SYNOPSIS
tk_menuBar frame ?menu menu ...? tk_bindForTraversal arg arg ... _________________________________________________________________ DESCRIPTION
These procedures were used in Tk 3.6 and earlier releases to help manage pulldown menus and to implement keyboard traversal of menus. In Tk 4.0 and later releases they are no longer needed. Stubs for these procedures have been retained for backward compatibility, but they have no effect. You should remove calls to these procedures from your code, since eventually the procedures will go away. From Tk 8.0 onwards, you should instead construct your menubar as a normal menu and then attach it to the toplevel of your choice using the -menu option of that widget. SEE ALSO
menu(1T), toplevel(1T) KEYWORDS
keyboard traversal, menu, menu bar, post ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTk | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tk is available on http://opensolaris.org. Tk tk_menuBar(1T)
All times are GMT -4. The time now is 03:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy