LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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

Reply
 
Search this Thread
Old 10-20-2010, 02:48 PM   #1
LinuxScript
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0
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
 
Old 10-20-2010, 02:59 PM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
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.
Old 10-20-2010, 03:20 PM   #3
LinuxScript
LQ Newbie
 
Registered: Oct 2010
Posts: 2

Original Poster
Rep: Reputation: 0
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.
 
Old 10-20-2010, 03:24 PM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by LinuxScript View Post
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?
 
Old 10-20-2010, 03:39 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
What are those "\c"s?
 
Old 10-20-2010, 07:16 PM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,442

Rep: Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880
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.
 
Old 02-03-2011, 12:24 AM   #7
jackonapsp
LQ Newbie
 
Registered: Jul 2010
Location: /home
Distribution: tty linux
Posts: 17

Rep: Reputation: 0
Smile man echo

Quote:
Originally Posted by MTK358 View Post
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,
 
Old 02-03-2011, 12:34 AM   #8
jackonapsp
LQ Newbie
 
Registered: Jul 2010
Location: /home
Distribution: tty linux
Posts: 17

Rep: Reputation: 0
Smile my version

Quote:
Originally Posted by LinuxScript View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
passing parameters from a unix shell prompt into a windows cmd.exe prompt nano2 Programming 1 09-01-2009 11:26 AM
Shell script sudo without password prompt under Darwin? lhouk Other *NIX 3 02-08-2008 11:16 AM
LXer: Shell tip: Set the shell prompt and themes in Linux Terminal LXer Syndicated Linux News 0 06-12-2007 03:02 AM


All times are GMT -5. The time now is 04:19 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration