LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 06: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, 09: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, 10:07 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
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-27-2013, 12:38 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
Seems to work just fine for GNU bash, version 4.2.39(1)-release
 
Old 02-27-2013, 09: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, 10:29 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,565

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


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

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

All times are GMT -5. The time now is 05:30 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration