Reading input to create a variable in a script?

I would like to prompt for input and then use it as a variable in a script.

Something like this.

#!/bin/ksh
echo "What is your name?: \c"
read response

echo "Your name is $reply" >file.txt
done
exit 0

What am I missing?

Thanks,

does this work for you?

#!/bin/ksh
echo "What is your name?: \c"
read response

echo "Your name is $response" >file.txt
exit 0

works for me

I didn't need done evidently.

Well, and also, did you notice this?:

You defined "response", but echo'd "reply".

---------------------
If you will use REPLY. (Give read no variable)
echo "What is your name ?" ; read
echo $REPLY #use big letters
---------------------
If you will use a variable
echo "What is your name ?" ; read TheNameIs
echo $TheNameIs
---------------------

Yes, I noticed that response and reply were typed incorrectly. That wasn't the actual code but an example I used when typing the message to this forum. Good catch.

Thanks for the tips. My script is running great.

_r�d,

So the difference between using any given string name and using $REPLY is that REPLY doesn't set a variable?

No, the difference was not using matching tokens in the script. You could have just as easily called the shell variable 'peanut_butter'.... as long as you use the same shell variable. The problem was a common programming error of mismatched shell variables.

In other words... response and reply (as shell variable) are irrelevent except as tokens..... the use of these terms in the example was to make the code more readable by humans.....

(unless the tokens are reserved words used by the shell for other purposes..... )