Linux Shell Script needs help writing program

Reply

Join Date: Mar 2004
Posts: 27
Reputation: STP72 is an unknown quantity at this point 
Solved Threads: 0
STP72 STP72 is offline Offline
Light Poster

Linux Shell Script needs help writing program

 
0
  #1
Jun 2nd, 2005
I have been tasked to write this shell script in Linux and I dont know how to begin. Can anyone help me out with this please.:cry:



Create a shell script file called “lookup� with a loop that prompts the user for a name to search on, reads a name the user inputs from the keyboard into a shell variable, prints the number of matches that are in your phonebook file as well as the matched name(s) and phone number(s), and keeps looping back until the user enters “quit�. Turn in the final code for this script. If your script doesn’t work, you can still get partial credit based on how close to making it work you get. Full credit will require appropriate spacing, indentation to make your script code easier to read, comments within the script documenting your code flow, and user friendly features/prompts. This will require that you use shell script variables, input, output, counting and looping commands. Your script must contain those types of shell script operations in order to receive full credit.

You will need to change the permissions on the “lookup� file so that it is executable before the script can be run, and you will also probably have to specify the path to the file to get it to run. (type /home/demo/lookup or ~/lookup or ./lookup)
:cool:
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Linux Shell Script needs help writing program

 
0
  #2
Jun 2nd, 2005
Just curious, what kind of a class is this for? I would probably recommend using bash, it is the easiest. Do you have any type of shell scripting experience?

you refer to a phonebook file, is this just a text document, if so could I see an example?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 27
Reputation: STP72 is an unknown quantity at this point 
Solved Threads: 0
STP72 STP72 is offline Offline
Light Poster

Re: Linux Shell Script needs help writing program

 
0
  #3
Jun 2nd, 2005
This is for my UNIX class and I have to use preferrably Bash. I have very little experience thats why I need some help to get started.
:cool:
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Linux Shell Script needs help writing program

 
0
  #4
Jun 2nd, 2005
what does the phonebook file look like?
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Linux Shell Script needs help writing program

 
0
  #5
Jun 2nd, 2005
lets go at it from this angle, what do you know about shell scripting or unix. Are you familiar with some commands?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 27
Reputation: STP72 is an unknown quantity at this point 
Solved Threads: 0
STP72 STP72 is offline Offline
Light Poster

Re: Linux Shell Script needs help writing program

 
0
  #6
Jun 3rd, 2005
I have a file called phonebook and these are the names in there. I am starting to learn the commands in my class, but dont know how to write scripts.



Auvenshine:JasonO Box 18076:85731:7905810
Sepulveda:Mary:7234 Lucky Lane:85705:5551212
Smith:John:3831 E. Camino Seco:85710:6034426
Crowder:LauraO Box 3261:85747:2771819
Garnettharon:19872 S. Camino Verde:85744:7293888


:cool:
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Linux Shell Script needs help writing program

 
0
  #7
Jun 3rd, 2005
I am guesing this assingnment is not do for a while?
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 27
Reputation: STP72 is an unknown quantity at this point 
Solved Threads: 0
STP72 STP72 is offline Offline
Light Poster

Re: Linux Shell Script needs help writing program

 
0
  #8
Jun 3rd, 2005
Its due next week as an extra credit assignment, but I really like to figure this out.
:cool:
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: Linux Shell Script needs help writing program

 
0
  #9
Jun 3rd, 2005
all a script is is a bunch of commands done in order. Do you have any ideas? from there we can guide you.
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 27
Reputation: STP72 is an unknown quantity at this point 
Solved Threads: 0
STP72 STP72 is offline Offline
Light Poster

Re: Linux Shell Script needs help writing program

 
0
  #10
Jun 3rd, 2005
This is what I have so far, let me know if this is the right, please:
The folder my phonebook is in is called 'phonebook'

1.Now how will I make the script search for names until I enter quit
2. Where would I put in the input value of the name, isnt it called '$1'
3. Also within the search I am doing, how can I make it display the name and phone number when I execute the program.
4. I think its the read command but I'm not sure

Finally, thanks for helping me out.


#! /bin/bash
phonebook=0
echo "Enter a name to search for"
:cool:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC