sudo 自动输入密码
 
 
 
  
  1. 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.
 
 
  
  1. echo "123456" | sudo -S chmod 777 test 
 
 rsync数据同步
 
  
  1. echo "123456" | sudo -S /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home  /home/vmail 

 

 
  
  1. sudo /usr/bin/rsync -vzrtopg --progress --delete --password-file=/etc/rsyncd.secrets root@192.168.10.100::home  /home/vmail << EOF  
  2. 123465  
  3. EOF