LinuxQuestions.org
Register a domain and help support LQ
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-01-2009, 06:49 PM   #1
incomingid
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Rep: Reputation: 0
Press to Continue


I'm making a script were the user has to enter one of the options: 1, 2, 3 or 4.
After he enters one of the options the script will do something for each(like a menu.

After the output of the chosen option is showed I want the user to be prompted to "Press any key to Continue", So the loop can go back to the menu.

menu:
EX.
1. add
2. subtract
3. divide
4. exit

Enter: 1

You chose "add"
Press any key to Continue
 
Old 04-01-2009, 09:52 PM   #2
incomingid
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Original Poster
Rep: Reputation: 0
Can anyone pls help.
 
Old 04-01-2009, 10:03 PM   #3
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,808

Rep: Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604Reputation: 604
So what's the problem and what do you have already?
 
Old 04-01-2009, 10:58 PM   #4
incomingid
LQ Newbie
 
Registered: Oct 2008
Posts: 15

Original Poster
Rep: Reputation: 0
I have my full script except the part were i want the user to press a key to continue. I'm looking for a command like "sleep", but the command should end when the user enters any key.
It's just a basic "Press a key to continue"
 
Old 04-02-2009, 08:18 AM   #5
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 10, Linux Mint 11
Posts: 148

Rep: Reputation: 18
Try this (assuming bash) ...

Code:
read -sn 1 junk
The '-sn 1' tells it to read just one character (the n), and to not echo the character (the s). junk is the name of the variable, and since you want it just to add a pause to your script, it is a junk variable. Something that can be thrown away because you don't really care what the user inputs.

Last edited by Hobbletoe; 04-02-2009 at 10:29 AM. Reason: Thought I would add the -s option to the command to prevent the character from being echoed.
 
  


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
Press enter for maintenance (or type Control-D to continue) scg03 Linux - Newbie 2 10-05-2008 01:24 AM
scripting question press any key to continue Mr.McCormick Programming 3 02-04-2005 04:47 AM
boot failed: please change disks and press a key to continue bonovox86uk Red Hat 2 12-08-2004 05:16 PM
Boot failed: please change disk and press a key to continue zeewin Linux - Software 4 01-05-2004 11:39 PM
Boot failed: please change disks and press a key to continue. ChriSchmi Linux - Software 9 03-13-2002 02:34 PM


All times are GMT -5. The time now is 10:39 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