There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware network networking outlook outlook 2003 outlook express partition password printer problem ram router security slow software sound trojan usb video virus vista windows windows xp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
Can anyone help me on my bsh shell script question. Thank you very much indeed!


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
06-Nov-2003, 02:08 AM #1
Question Can anyone help me on my bsh shell script question. Thank you very much indeed!
How to write these shell scripts?

Menu options are as follows:

1.Lookup help on a command using man
2.Display file system disk space usage in megabytes
3.Display memory usage in megabytes with a line containing totals
4.List all current processes
5.Monitor top system processes
6.Display system uptime
7.Exit User Menu
Squashman's Avatar
Distinguished Member with 12,698 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
06-Nov-2003, 02:18 AM #2
Why do you need this. Sounds like it would just slow a person down by using a menu to select from.
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
06-Nov-2003, 02:48 AM #3
You will need some form of a while loop to control the overall logic (for example, a loop that executed as long as the selection was not "exit"). On each iteration of the loop, you will display the menu of choices, accept the user input, validate the input, and execute the associated command. When the command completes, control should return to the top of the loop (re-display menu, etc.).

Depending on how you choose to structure your program, you will need shell constructs such as while, read, if-then and case. Why not start with one of the options that you feel comfortable with, and write a script that will prompt for input ("should I execute this command Y/N?"), read and validate the response, and execute the command if requested. Once you've done one, you'll be well on your way to coding the complete menu system.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
06-Nov-2003, 05:21 AM #4
Quote:
Originally posted by LwdSquashman:
Why do you need this. Sounds like it would just slow a person down by using a menu to select from.
It is my linux exercise. i have to finish it by this week.
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
06-Nov-2003, 05:26 AM #5
Quote:
Originally posted by codejockey:
You will need some form of a while loop to control the overall logic (for example, a loop that executed as long as the selection was not "exit"). On each iteration of the loop, you will display the menu of choices, accept the user input, validate the input, and execute the associated command. When the command completes, control should return to the top of the loop (re-display menu, etc.).

Depending on how you choose to structure your program, you will need shell constructs such as while, read, if-then and case. Why not start with one of the options that you feel comfortable with, and write a script that will prompt for input ("should I execute this command Y/N?"), read and validate the response, and execute the command if requested. Once you've done one, you'll be well on your way to coding the complete menu system.

Hope this helps.
Yes, it is help! thank you very much!!

Actually it's shame i dont know any about shell script, i just
started to learn linux last week. but i have to finish this
exercise by this week...so i quite worry
Squashman's Avatar
Distinguished Member with 12,698 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
06-Nov-2003, 12:13 PM #6
I found this little menu driven script. You could probably edit it to do what you want it to do.
Attached Files
File Type: txt menu.txt (1.9 KB, 126 views)
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
06-Nov-2003, 02:01 PM #7
I suspect that if you post your code and ask specific questions about whatever problems you are having, folks here will be more than happy to help. Good luck on your assignment -- Linux/Unix can be difficult to learn, but rewards careful study many times over.
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
06-Nov-2003, 10:30 PM #8
I have just finished my script...but i dont know is it right.
Could anyone possible to check for me?
Thank you very much!!!
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
07-Nov-2003, 12:55 AM #9
You can check for syntax errors by invoking your script as:

sh -n scriptname

and you can run your script with each line printing (with variable substitution) as it executes by invoking your script as:

sh -x scriptname

These are excellent debugging tools. If you are still having trouble, post your script with your specific question(s), and I'm sure you'll find people willing to help you.
__________________
The slowest component still sits at the keyboard.
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
07-Nov-2003, 06:02 AM #10
Quote:
Originally posted by codejockey:
You can check for syntax errors by invoking your script as:

sh -n scriptname

and you can run your script with each line printing (with variable substitution) as it executes by invoking your script as:

sh -x scriptname

These are excellent debugging tools. If you are still having trouble, post your script with your specific question(s), and I'm sure you'll find people willing to help you.
I don't have linux at my machine, but i can try next monday at uni Cheers
seegu's Avatar
Junior Member with 6 posts.
 
Join Date: Nov 2003
07-Nov-2003, 10:00 PM #11
Quote:
Originally posted by codejockey:
You can check for syntax errors by invoking your script as:

sh -n scriptname

and you can run your script with each line printing (with variable substitution) as it executes by invoking your script as:

sh -x scriptname

These are excellent debugging tools. If you are still having trouble, post your script with your specific question(s), and I'm sure you'll find people willing to help you.
Hv u seen my script? any suggestion?cheers
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:27 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.