shell 自动输入密码

原文地址:http://biancheng.dnbcw.info/linux/297018.html

在shell脚本中需要用root用的来执行指令:

sudo 自动输入密码
 
echo "password" | sudo -S netstat -tlnp
 
       -S          
The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device.

原文地址:https://www.cnblogs.com/wangkangluo1/p/2155142.html