Linux 类系统自动输入密码

https://blog.csdn.net/wangbole/article/details/17579463

解决方法: echo + | (管道)

开始使用 

[plain] view plain copy

  1. echo "admin" | sudo service tomcat7 stop  

始终提示输入密码

后来查看了下sudo命令的使用

[plain] view plain copy

  1. man sudo  

发现有如下的解释:

-S          The -S (stdin) option causes sudo to read the password from
                   the standard input instead of the terminal device.  The
                   password must be followed by a newline character.

猜你喜欢

转载自my.oschina.net/macleo/blog/1805339