Unix Shell Script to prompt customer for name etc

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Unix Shell Script to prompt customer for name etc
# 1  
Old 10-20-2010
Unix Shell Script to prompt customer for name etc

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:
How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, product, price range.

Thanks


2. Relevant commands, code, scripts, algorithms:

none

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

echo "Enter your name:> \c"
read name

echo "enter your age:> \c"
read age

echo "enter address:> \c"
read address

echo "enter phone number:> \c"
read phone number

echo


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
I explained to a moderator yesterday that I am teaching myself unix.

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).
# 2  
Old 10-20-2010
You're on the right track. You cannot use a variable that consists of two words.
Code:
read phone number

puts the answer in the variable "phone" or the part before the first whitespace in the variable "phone" and the remainder in the variable "number".
# 3  
Old 10-20-2010
When someone enters the information, it should not be lost when the script terminates. So you will have to write the information on harddisk in just a plain text file. Best would be to use some symbol as separator to keep the fields separated. One line will represent one data set of a customer.

Code:
DATFILE=./customer.dat

echo "Enter your name:> \c"
read name

echo "Enter....
....
...

echo "$name:$age:$address:$phone" >> $DATFILE

After you're done with it, cat the customer.dat to see it's contents.

Next step will be to think about how you will retrieve this info stored in that text file - there are several options how to do that. What field or string should be able to be searched for - how will the result be displayed etc. ie. should all infos be displayed or only some.
# 4  
Old 10-20-2010
zaxxon asked:

Next step will be to think about how you will retrieve this info stored in that text file - there are several options how to do that. What field or string should be able to be searched for - how will the result be displayed etc. ie. should all infos be displayed or only some.

Reply:
Name, age and address should be displayed.
# 5  
Old 10-20-2010
Don't expect a ready-to-go script. You have basically 2 kind of functions your script will do:
  1. Take input and write to a file
  2. Take a search pattern to retrieve information
So you will maybe have a little menue or something in the beginning, where the user can choose if data should be added or searched.
You could script that with a read command, presenting 3 options where the third would be to exit for example. This input can be checked out with case/esac statement.
I'd say you best try to write the script with all the hints we presented so far and when it is ok and works so far, we go for the data retrieve part. Else you would not learn much from all this.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Noob. shell script with prompt?

Hey Guys and Gals, Im a complete Noob to Unix. But recently have started working on a unix system for my PET/CT scanner. My scanner comes with a MOD drive for backup. I would like to back up to USB (its alot cheaper). But the only way to do so is by manually enterin the unix commands. Id like to... (13 Replies)
Discussion started by: TorresGXL
13 Replies

2. Homework & Coursework Questions

Shell Script Password Prompt

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: I am trying to write a shell script that prompts the user for the password which is "lux" once the correct password... (4 Replies)
Discussion started by: Emin_Em
4 Replies

3. Shell Programming and Scripting

Use Unix shell script to open Windows command prompt (cmd)

Hello, I work on Windows and I use Putty to access a remote UNIX server. I am trying to build a shell script that will have as main task to open the Windows command prompt (cmd) and run some Windows commands thereafter. The commands are actually file transfer commands that will download a file... (14 Replies)
Discussion started by: rookie2785
14 Replies

4. UNIX for Dummies Questions & Answers

Shell Script to prompt customer for name etc

reposting How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, product, price range. Thanks (1 Reply)
Discussion started by: SQLScript
1 Replies

5. Shell Programming and Scripting

Shell Script to prompt customer for name etc

How do I create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, product, price range. Thanks (1 Reply)
Discussion started by: SQLScript
1 Replies

6. Shell Programming and Scripting

echo in alias for Unix C-Shell Prompt

Hi, I want to set Unix prompt in C-Shell which required the break new line using alias. Ex. hostname : username : %> Now, it will be setup in .login file with alias alias cd 'cd \!* | set prompt="`hostname` : $USER : %>"' I'm unable to parse echo command or break which I can get %>... (3 Replies)
Discussion started by: buzzusa
3 Replies

7. AIX

echo in alias for Unix C-Shell Prompt

Hi, I want to set Unix prompt in C-Shell which required the break new line using alias. Ex. hostname : username : %> Now, it will be setup in .login file with alias alias cd 'cd \!* | set prompt="`hostname` : $USER : %>"' I'm unable to parse echo command or break which I can get %>... (1 Reply)
Discussion started by: buzzusa
1 Replies

8. UNIX for Dummies Questions & Answers

identify a customer under a UNIX server

Like many UNIX users, there is a small team that is connected to UNIX (under the same UNIX user) via putty from a Windows PC. Is there a way, once under UNIX, to know the address of the originating computer or anything that can differentiate initial users ? (7 Replies)
Discussion started by: popescu1954
7 Replies

9. Shell Programming and Scripting

script to change shell and prompt

I want to write a shell script which will change the current shell (say from csh to bsh) and my Prompt (say my name) as desired.pls help (1 Reply)
Discussion started by: SHYAM
1 Replies
Login or Register to Ask a Question