LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices



Closed Thread
 
Search this Thread
Old 12-28-2004, 02:17 AM   #1
farmerjoe
Member
 
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?
>test
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.

Thanks!
famerjoe

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

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

Here are 2 ways of doing it:

Code:
#/bin/ksh

# 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, 06:18 AM   #3
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,176
Blog Entries: 4

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

http://www.linuxquestions.org/rules.php

Go here: http://www.linuxquestions.org/questi...hreadid=271028
 
  


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 04:46 PM
Make script wait for input farmerjoe Linux - General 4 12-28-2004 02:49 AM
bash-script won't wait for application to finish TLV Linux - Software 24 10-01-2004 12:18 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
Pppd does not wait for chat script to finish ruchika Programming 1 08-29-2003 12:30 AM


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

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