LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-24-2010, 10:59 AM   #1
indur
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Rep: Reputation: 0
catching keybord input


IS there a way to continue a script after "the any key" is pressed by a user?

I know there's the command "read" but then the input is put into a variable. Now i wan't to continue the script without comparing the user input.

I tried something like this:

echo "Press any key to continue"
read input

if [ $input = true ]; then
echo "Ok here we go"
fi
Also with a wild card but it doesn't work properly.

Is there perhaps another way then with the "read" function?
 
Old 04-24-2010, 11:05 AM   #2
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
So you want to continue unconditionally if a key is pressed?

Try this:

Code:
echo "Press enter to continue"
read
echo "Ok here we go"
It must be Enter because the shell buffers input until Enter is pressed. And who ever said that you *have* to compare read's output in an if block?
 
Old 04-24-2010, 11:06 AM   #3
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Hi indur,

Please change your if statement to

Code:
if [ $input ]
 
Old 04-24-2010, 11:07 AM   #4
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
http://tldp.org/LDP/abs/html/internal.html#EX36
 
Old 04-24-2010, 11:10 AM   #5
indur
LQ Newbie
 
Registered: Apr 2010
Posts: 8

Original Poster
Rep: Reputation: 0
@ vinaytp

That simple!

Nice tnx!

@ MTK358

That was not wat i had in mind but tnx anyway.
 
Old 04-24-2010, 11:13 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Please do not use texting shorthand here.
what
thanks
 
  


Reply


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Catching keyboard meessages/input to a GTK(sharp) textview widget True_Friend Programming 0 07-13-2008 09:49 PM
keybord config. GlupFire Slackware 3 04-08-2008 05:21 PM
keybord ???????? joe108 Debian 1 08-06-2007 12:42 AM
Keybord not working ValidiusMaximus Linux - Laptop and Netbook 0 01-05-2005 05:07 PM
Keybord layer Getafix Linux - Newbie 0 10-11-2004 09:28 AM


All times are GMT -5. The time now is 02:25 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration