LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-26-2013, 05:31 PM   #1
zousheng
LQ Newbie
 
Registered: Feb 2013
Location: China
Posts: 29

Rep: Reputation: Disabled
shell read -p -s hanging, need to press enter key twice to make it run


Hi, when i try to input the password with read -s -p "": variable
then it's hanging, it needs me to press the enter key twice, don't know why, anyone can help? thanks
 
Old 02-26-2013, 08:58 PM   #2
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Take a note that, option -s is used for supress or silent, and -p is for prompt, so use only -s.

If you want to hide the password, just do it like,
Code:
echo -n "Enter password: "
read -s passwd
 
Old 02-26-2013, 09:07 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by shivaa View Post
Take a note that, option -s is used for supress or silent, and -p is for prompt, so use only -s.
Using or leaving out '-p "";' doesn't have any effect on 'read' when using BASH 3.2.25(1) so this doesn't explain his observation of having to use enter twice.
 
Old 02-26-2013, 11:38 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Seems to work just fine for GNU bash, version 4.2.39(1)-release
 
Old 02-27-2013, 08:12 AM   #5
zousheng
LQ Newbie
 
Registered: Feb 2013
Location: China
Posts: 29

Original Poster
Rep: Reputation: Disabled
Thanks for all your information, today i found the reason by accident. i put a if sentence and some other command after read, then after i input password, it didn't give reply at all, like it's still waiting me to input the password, but the fact is it's already running, then i add an echo "Program is running, please wait for a while...", then after I input the password, Program is running, please wait for a while... shows immediately, then i figured out this is the reason. thanks again.
 
Old 02-27-2013, 09:29 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Please mark as SOLVED once you have a solution.
 
  


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
[SOLVED] read ENTER KEY from Keyboard KaRt Linux - Newbie 12 07-26-2012 03:46 PM
Boot hanging on HP PC w/ Ubuntu unless I press key photoelectricgeek Linux - Hardware 9 03-08-2011 08:56 PM
How to make shell script wait for key press to proceed... ddenton Linux - General 13 12-02-2008 04:25 AM
Bios hanging at press Del to enter setup screen for full minute randrake Linux - Hardware 3 02-27-2006 07:54 AM

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

All times are GMT -5. The time now is 10:14 PM.

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