In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to convert the input password into * in the Shell script, which has a certain reference value. Interested friends can refer to it. I hope you can learn a lot after reading this article.
If you need to write a paragraph that interacts with the user and needs to enter some sensitive information (such as user password, License, etc.), then the information entered by the user will be displayed on the screen by using printf+read directly, which is not in line with information security and is not professional enough for the customer experience, so you need to convert the password entered by the user to *, as follows:
Please input your passwd:1234
Modified to:
Please input your passwd:****
So how to achieve it? please read on.
#! / bin/shgetchar () {stty cbreak-echo dd if=/dev/tty bs=1 count=1 2 > / dev/null stty-cbreak echo} printf "Please input your passwd:" while:; do ret= `getchar` if [x$ret = x] Then echo break fi str= "$str$ret" printf "*" doneecho "Your password is: $str" Thank you for reading this article carefully. I hope the article "how to convert the entered password into *" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.