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
awk user input gefa Shell Programming and Scripting 17 10-30-2007 02:01 AM
Getting user input stevefox Shell Programming and Scripting 3 02-15-2007 11:09 PM
making sure input are digits bebop1111116 High Level Programming 1 10-21-2006 02:32 PM
Accepting User Input scott78 Shell Programming and Scripting 1 01-13-2004 11:54 AM
Wait for input keelba UNIX for Dummies Questions & Answers 0 04-26-2002 08:44 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-15-2001
Registered User
 

Join Date: Nov 2001
Location: ny
Posts: 1
Question making a .sh wait for user input

I need a script to halt at the end and wait for the user to hit a key...could be any ket or enter. I know it can be done but I am just starting out.. Thanks
Forum Sponsor
  #2  
Old 11-15-2001
PxT's Avatar
PxT PxT is offline
Registered User
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
echo "Hit return to continue"
read dummy_variable
  #3  
Old 11-16-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
To allow them to continue after hitting any key, I usually create a function (I usually call it readOne, after the function I stole the idea from ):
Code:
readOne () {
tput smso
echo "Press any key to return \c"
tput rmso
oldstty=`stty -g`
stty -icanon -echo min 1 time 0
dd bs=1 count=1 >/dev/null 2>&1
stty "$oldstty"
echo
}
The call it later from the script:

blah blah ...
readOne
blah blah
exit 0


HTH
  #4  
Old 11-16-2001
PxT's Avatar
PxT PxT is offline
Registered User
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
Interesting use of dd. Nice post.
  #5  
Old 11-16-2001
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Very interesting. I've never seen a way to read a single character from a shell script before. But I want to be able to actually catch the character that is typed. So I changed the dd statement to:
result=`dd bs=1 count=1 2>/dev/null`
which seems to be working. Very cool trick!
  #6  
Old 01-21-2004
Registered User
 

Join Date: Nov 2003
Location: seattle
Posts: 8
Hi,

Well I was trying to see what exactly the script Livinfree posted is doing.

I couldnt understand.

Using man I could get that tput smso and rmso is for getting standout mode seq started and end it.
dd bs sets the blcok size to 1.But why I didnt undertand. Is it because the requirement is that only ONE keystroke is required.

however I couldnt understand how the rest of these work when put together.

Could anyone pls explain.

Thanks.
  #7  
Old 01-21-2004
Registered User
 

Join Date: Nov 2003
Location: seattle
Posts: 8
and I am a fool it seems...Was looking at todays thread and dont know why I ended up on a thread 2 years old!
Sorry folks....Ignore my previous mail... by mistake I thought this thread is new.

Thanks
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:31 AM.


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