ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi 2 all friends...
I just write a script that check some thing. and I use
Code:
read -p " enter : " chk
it executed. but if a user use "Enter key" on keyboard it cant continue and finish.
I hope I explain well ...
if u can please guide me..
thanks
Do you mean that the script you wrote supposed to do something after read, but it stops after executing the read command?
The command "read" reads a line from standard input till the user hits the "Enter key". So read command is supposed to exit after the one presses "Enter".
Sorry, but I do not clearly understand what is your problem. Can you explain a little more what your script is supposed to do?
It execute completely and and do whatever should to do. But I mean i want to disable " Enter key" on keyboard during that script is executing and users wont be able to stop my script by pressing Enter key.
you know if user press "Enter" it can not continue and will stop
Last edited by keimasi; 02-24-2011 at 12:40 PM.
Reason: add something..........
It execute completely and and do whatever should to do. But I mean i want to disable " Enter key" on keyboard during that script is executing and users wont be able to stop my script by pressing Enter key.
you know if user press "Enter" it can not continue and will stop
Sorry, I am still confused!
Pressing "Enter" as a response to the "read" command in your script should not stop the script. Is it stopping the script? How is user able to stop the script by pressing "Enter key"?
I believe, "read" needs a "Enter" to understand the stdin has ended. So I am not sure "disabling Eneter key" will be possible at all if you are reading from stdin.
If you want to prevent user entering blank line as a response to the read command, you can follow what prowla suggested.
If this is not the case, can you please post the relevant parts of the script (replacing sensitive information, of course), the intended output, and the output when the user presses enter after the read statement and the script stops?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.