Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-20-2010, 02:48 PM
|
#1
|
|
LQ Newbie
Registered: Oct 2010
Posts: 2
Rep:
|
Shell Script to prompt customer
I need to create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, and product.
Below is what i have so far. Thanks for the assistance
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 phonenumber
echo "enter product:> \c"
read product
|
|
|
|
10-20-2010, 02:59 PM
|
#2
|
|
Moderator
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,816
Rep: 
|
Looks like you are on the right track. Echo the values back out with the echo command. echo $name
Are you stuck somewhere?
|
|
|
1 members found this post helpful.
|
10-20-2010, 03:20 PM
|
#3
|
|
LQ Newbie
Registered: Oct 2010
Posts: 2
Original Poster
Rep:
|
Yes im stuck. the file should be an executable. When the file is executed it prompts the user to input name, age etc
To make the file executable i will use:
chmod 777 cusinfo
./cusinfo
but im missing something to make it prompt the user to enter information
Last edited by LinuxScript; 10-20-2010 at 03:21 PM.
|
|
|
|
10-20-2010, 03:24 PM
|
#4
|
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,466
Rep: 
|
Quote:
Originally Posted by LinuxScript
but im missing something to make it prompt the user to enter information
|
What do you mean? You seem to have the right statements in there. Are you getting error messages or something?
|
|
|
|
10-20-2010, 03:39 PM
|
#5
|
|
LQ 5k Club
Registered: Sep 2009
Distribution: Arch x86_64
Posts: 6,443
|
What are those "\c"s?
|
|
|
|
10-20-2010, 07:16 PM
|
#6
|
|
Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 6,328
|
Quote:
|
Originally Posted by MTK358
What are those "\c"s?
|
I was curious about that too??
Are you perhaps trying to have them enter say there name on the same line as the prompt?
Choices would be:
Code:
echo -n "Enter your name:> "
read name
# or
read -p "Enter your name:> " name
Last edited by grail; 02-03-2011 at 01:08 AM.
|
|
|
|
02-03-2011, 12:24 AM
|
#7
|
|
LQ Newbie
Registered: Jul 2010
Location: /home
Distribution: tty linux
Posts: 17
Rep:
|
man echo
Quote:
Originally Posted by MTK358
What are those "\c"s?
|
man echo
The following option is available:
-n Do not print the trailing newline character. This may also be
achieved by appending `\c' to the end of the string,
|
|
|
|
02-03-2011, 12:34 AM
|
#8
|
|
LQ Newbie
Registered: Jul 2010
Location: /home
Distribution: tty linux
Posts: 17
Rep:
|
my version
Quote:
Originally Posted by LinuxScript
I need to create a shell script called 'custinfo' to prompt a customer to enter and display back the following: name, age, address, phone number, and product.
Below is what i have so far. Thanks for the assistance
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 phonenumber
echo "enter product:> \c"
read product
|
here is my version
#!/bin/bash
mkdir info
cd info
echo "Enter your name:>"
read name
mkdir $name
cd $name
echo "enter your age:>"
read age
echo "enter address:>"
read address
echo "enter phone number:>"
read phonenumber
echo "enter product:>"
read product
echo $age > age.txt
echo $address > address.txt
echo $phonenumber > phnumber.txt
echo $product > product.txt
|
|
|
|
| Thread Tools |
Search 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
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:13 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|