HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: silent read
Operating System - HP-UX
1834608
Members
2754
Online
110069
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2005 02:45 AM
06-29-2005 02:45 AM
I'm writing a shell script,and I want to accept a password from the user, but I don't want the echo output to screen. (as READ does).
I'm being lazy as I could write the script in PERL or C but I'd prefer to KISS and do it as a UNIX shell.
I'm being lazy as I could write the script in PERL or C but I'd prefer to KISS and do it as a UNIX shell.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2005 02:51 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2005 03:01 AM
06-29-2005 03:01 AM
Re: silent read
While all you need to do is a stty -echo, it is very important that the terminal not be left in this state (process dies, or n'rupt before doing a stty echo). You should always have a trap to reset the terminal because the tty settings affect not just this process but the terminal device itself.
The better way is:
#!/usr/bin/sh
echo "Enter password: \c"
trap 'stty echo' 0 1 2 15
stty -echo
read PW
stty echo
Now no matter if you enter a Ctrl-C, for example, the terminal will be restored to sane vales. I suggest the you omit the trap and Cntl-C the password entry to see what I am talking about.
------------------------------
The better way is:
#!/usr/bin/sh
echo "Enter password: \c"
trap 'stty echo' 0 1 2 15
stty -echo
read PW
stty echo
Now no matter if you enter a Ctrl-C, for example, the terminal will be restored to sane vales. I suggest the you omit the trap and Cntl-C the password entry to see what I am talking about.
------------------------------
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-29-2005 03:14 AM
06-29-2005 03:14 AM
Re: silent read
thanks to Rodney Hills & A. Clay Stephenson
stty -echo
read x
stty echo
or
echo "Enter password: \c"
trap 'stty echo' 0 1 2 15
stty -echo
read PW
stty echo
Oh and my good friend Leigh
stty -echo
read x
stty echo
or
echo "Enter password: \c"
trap 'stty echo' 0 1 2 15
stty -echo
read PW
stty echo
Oh and my good friend Leigh
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP