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.
- echo "123456" | sudo -S chmod 777 test
rsync数据同步
- echo "123456" | sudo -S /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home /home/vmail
- sudo /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home /home/vmail << EOF
- 123465
- EOF
转载于:https://blog.51cto.com/151wqooo/1169233