LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 05: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, 08:52 PM   #2
incomingid
LQ Newbie
 
Registered: Oct 2008
Posts: 15

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

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
So what's the problem and what do you have already?
 
Old 04-01-2009, 09: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, 07:18 AM   #5
Hobbletoe
Member
 
Registered: Sep 2004
Location: Dayton, Oh
Distribution: Linux Mint 17
Posts: 150

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 09:29 AM. Reason: Thought I would add the -s option to the command to prevent the character from being echoed.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:21 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
Open Source Consulting | Domain Registration