Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prompt user + add to file

Status
Not open for further replies.

shyg

Technical User
Jul 12, 2004
20
0
0
US
I am trying to prompt the user to enter info then once they have entered the info for the fields then >> the new info to an exisiting file.

Sample Code:
------------
echo Enter a userid:$1
echo Enter the first name:$2
echo Enter the last name:$3
$1+$2+$3 >> users.ref

I want to keep the $1,$2, and $3 data all on the same line seperated by only single spaces.

Also if someone could show me how to reverse the process as well that would be useful.
 
Try this:
Code:
#!/bin/ksh
echo "Enter a userid:\c"
read usr
echo "Enter the first name:\c"
read fnm
echo "Enter the last name:\c"
read lnm
echo "$usr $fnm $lnm" >> users.ref

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
On some flavors of Unix you also can use:
Code:
#!/bin/ksh
read usr ? "Enter a userid:"
read fnm ? "Enter the first name:"
read lnm ? "Enter the last name:"
echo "$usr $fnm $lnm" >> users.ref



----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top