The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-13-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
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  
Old 12-13-2001
Registered User
 

Join Date: Sep 2001
Location: Green Bay, WI
Posts: 66
Thumbs up

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  
Old 12-13-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
Works now

I didn't need done evidently.
  #4  
Old 12-13-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Well, and also, did you notice this?:

Quote:
read response

echo "Your name is $reply" >file.txt
You defined "response", but echo'd "reply".
  #5  
Old 12-14-2001
Registered User
 

Join Date: Nov 2001
Location: BehindThe7Hills
Posts: 3
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  
Old 12-14-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
?

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  
Old 12-14-2001
Registered User
 

Join Date: Dec 2001
Location: Overland Patrk
Posts: 62
_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
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 12:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0