-   Linux - General (
-   -   How to make a script wait for input (

farmerjoe 12-28-2004 01:17 AM

How to make a script wait for input?
How do i make a script wait for user input to declare a variable?

like say i wanted it to do this:

What would you like the variable to be?
Your variable is test.

I want to pause and wait for the user to input something that will declare a variable to be that input.

Any help is greatly appreciated. I am a n00b to all of this of course.


druuna 12-28-2004 04:54 AM


Here are 2 ways of doing it:



# Question and answer in one statement. The ?"<text>" is the part for the text you want/need to display

read aok?"Can we continue (y|n) : "

echo $aok

# Here text and answer are 2 commands. echo for the text, and read for the input.

echo "Can we continue (y|n) : \c"
read aok

echo $aok

Hope this helps.

PS: Can also be done with bash.

XavierP 12-28-2004 05:18 AM

Please do not post the same thread in more than one forum. Picking the most relevant forum and posting it once there makes it easier for other members to help you and keeps the discussion all in one place.

Go here:

All times are GMT -5. The time now is 02:16 AM.