LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 05-23-2004, 09:13 AM   #1
Toshi3
LQ Newbie
 
Registered: May 2004
Distribution: Red Hat 9
Posts: 20

Rep: Reputation: 0
shell command for pausing


Hi,

Is there a shell command that will "sleep" until a key is pressed (similar to getch() in C)?

Thanks,

Toshi
 
Old 05-23-2004, 10:40 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
You can use:
read -n1

Or slightly better:
read -sn1 -p "Press any key to continue..."

Last edited by david_ross; 05-23-2004 at 10:44 AM.
 
Old 05-23-2004, 11:04 AM   #3
Toshi3
LQ Newbie
 
Registered: May 2004
Distribution: Red Hat 9
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks,

read works fine in bash, but what about csh and tcsh ?

I would appreciate any help,

Toshi
 
Old 05-23-2004, 01:17 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I don't tend to write anything in shells other than bash but you could always start bash to run it:
bash -c "read -sn1"

If you want something that will work in all shells then you'll need an additional program such as pak.c:
Code:
#include <stdio.h>

int main(void)
{
 printf("Press any key to continue...");
 while (getchar() == EOF);
 printf("\n");
 return 0;
}
gcc -o pak pak.c
 
Old 05-23-2004, 03:10 PM   #5
Toshi3
LQ Newbie
 
Registered: May 2004
Distribution: Red Hat 9
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks a lot!

bash -c "read -sn1" is perfect.

Toshi
 
  


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
Pausing the screen JStew Programming 8 02-27-2007 08:47 AM
Pausing a program kamransoomro84 Linux - General 0 05-08-2004 04:25 PM
what is the shell command to.... praefex Linux - Newbie 2 08-18-2003 05:25 PM
shell command i_is_cat Linux - General 1 08-13-2003 03:09 AM
Pausing downloads KptnKrill Linux - Newbie 3 07-28-2003 09:30 PM


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