如何使bash脚本要求密码?

前端之家收集整理的这篇文章主要介绍了如何使bash脚本要求密码?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想用密码保护程序的执行。

我如何在bash中这样做?

谢谢

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

猜你在找的Bash相关文章