Results 1 to 7 of 7
I could use some help inwriting this script - I know it is a loop but am having trouble:
I need a script that will prompt for the user’s first ...
- 02-16-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 11
desperate need some help with script
I could use some help inwriting this script - I know it is a loop but am having trouble:
I need a script that will prompt for the user’s first name and store it in a variable. Then prompt for the last name and store it in a variable. Finally, display the stored information in the format “You entered lastname, firstname” and ask the user for confirmation. If the answer is “y” or “yes” then say “Thank you!” if the answer is “n” or “no” then start again with the prompts.
- 02-16-2009 #2Just Joined!
- Join Date
- Feb 2009
- Posts
- 7
Are you wanting to do this with Bash/Perl/C?
- 02-16-2009 #3Just Joined!
- Join Date
- Feb 2009
- Posts
- 11
iam using puppy linux
- 02-16-2009 #4Just Joined!
- Join Date
- Feb 2009
- Posts
- 11
yes bash is ok
- 02-16-2009 #5Just Joined!
- Join Date
- Feb 2009
- Posts
- 11
so far i have :
#!/bin/bash
declare FName
read -p "enter first name" : "$Fname
declare LName
read -p "enter last name" : "$Lname
- 02-16-2009 #6Just Joined!
- Join Date
- Feb 2009
- Posts
- 11
actually i have this now:
#!/bin/bash
declare FName
read -p "Enter First Name : " FName
declare LName
read -p "Enter Last Name : " LName
echo "you entered" $FName $LName
echo "is that correct?"
- 02-17-2009 #7Just Joined!
- Join Date
- Feb 2009
- Posts
- 7
I must admit I'm not fantastic with bash scripting, but this is what I came up with:
Edit: Edited out a hyphen that copied over from vimCode:#!/bin/bash function readName { read -p "Enter first name: " FName read -p "Enter last name: " LName echo "You entered $FName $LName" read -p "Is this correct (y or n)?" valid if [ $valid = "y" ]; then echo "correct!" else readName fi } readName


Reply With Quote