如何使bash脚本询问密码? [英] How to make bash script ask for a password?

查看:82
本文介绍了如何使bash脚本询问密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用密码保护程序的执行。

我怎么做,在bash中?

感谢您


解决方案

  stty_orig =`stty的-g`#保存原来的终端设置。
的stty -echo#关断呼应。
读passwd文件#读取密码
stty的$#stty_orig恢复终端设置。

I want to secure execution of a program with a password.

How do i do that in bash ?

Thank you

解决方案

stty_orig=`stty -g` # save original terminal setting.
stty -echo          # turn-off echoing.
read passwd         # read the password
stty $stty_orig     # restore terminal setting.

这篇关于如何使bash脚本询问密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆