Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


Closed Thread
  Search this Thread
Old 12-28-2004, 01:17 AM   #1
Registered: Oct 2004
Location: Texas
Distribution: Ubuntu - Home, RHEL4 - Server
Posts: 96

Rep: Reputation: 15
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.


Last edited by farmerjoe; 12-28-2004 at 01:19 AM.
Old 12-28-2004, 04:54 AM   #2
LQ Veteran
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389Reputation: 2389

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.
Old 12-28-2004, 05:18 AM   #3
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 471Reputation: 471Reputation: 471Reputation: 471Reputation: 471
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:

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how can I take input with a shell script? GUIPenguin Linux - General 4 04-11-2005 03:46 PM
Make script wait for input farmerjoe Linux - General 4 12-28-2004 01:49 AM
bash-script won't wait for application to finish TLV Linux - Software 24 09-30-2004 11:18 PM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM
Pppd does not wait for chat script to finish ruchika Programming 1 08-28-2003 11:30 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration