![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading input from user | vadharah | Shell Programming and Scripting | 2 | 03-09-2008 07:35 AM |
| Help reading an input file in KSH | zilla30066 | Shell Programming and Scripting | 2 | 02-01-2007 03:45 AM |
| Script for reading an input file | gzs553 | Shell Programming and Scripting | 1 | 10-17-2006 03:55 AM |
| reading from input | nageshrc | Shell Programming and Scripting | 1 | 11-29-2001 03:15 PM |
| Reading Input in a Script | alwayslearningunix | UNIX for Dummies Questions & Answers | 2 | 03-30-2001 09:48 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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, |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
Works now
I didn't need done evidently.
|
|
#4
|
||||
|
||||
|
Well, and also, did you notice this?:
Quote:
|
|
#5
|
|||
|
|||
|
Reading input to create a variable in a script?
---------------------
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 --------------------- |
|
#6
|
|||
|
|||
|
?
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. |
|
#7
|
|||
|
|||
|
_r€d
_r€d,
So the difference between using any given string name and using $REPLY is that REPLY doesn't set a variable? |
|||
| Google The UNIX and Linux Forums |