spawn rsync -avH --delete /home/dwetl/bin dwetl@10.128.8.151:/home/dwetl/bin sending incremental file list bin/ bin/ftpgj.log bin/ftpjx.log bin/perl_add_gms.log bin/perl_add_ib.log bin/perl_add_uprr.log bin/runjob_imp_gms.sh bin/runjob_perl_ib.sh bin/20120426/ bin/20120427/ bin/20120615/ sent 62027 bytes received 523 bytes 41700.00 bytes/sec total size is 928342848 speedup is 14841.61 expect: spawn id exp4 not open while executing "expect "*"" spawn rsync -avH --delete /home/dwetl/sbin dwetl@10.128.8.151:/home/dwetl/sbin sending incremental file list sbin/cust.txt sbin/date.txt sbin/jkall.log sbin/jksuccess.log sbin/tmp.txt sbin/tmp1.txt sent 106870 bytes received 511 bytes 214762.00 bytes/sec total size is 1976832 speedup is 18.41 expect: spawn id exp4 not open while executing "expect "*"" spawn rsync -avH --delete /home/dwetl/perl_script dwetl@10.128.8.151:/home/dwetl/perl_script sending incremental file list sent 22952 bytes received 26 bytes 15318.67 bytes/sec total size is 746771078 speedup is 32499.39 expect: spawn id exp4 not open while executing "expect "*"" 仓库DB-ORACLE /home/dwetl/bin$ sh /home/dwetl/bin/rsync_dwetl.sh spawn rsync -avH --delete /home/dwetl/bin dwetl@10.128.8.151:/home/dwetl/bin dwetl@10.128.8.151's password: sending incremental file list sent 15637 bytes received 81 bytes 10478.67 bytes/sec total size is 928342848 speedup is 59062.40 spawn rsync -avH --delete /home/dwetl/sbin dwetl@10.128.8.151:/home/dwetl/sbin dwetl@10.128.8.151's password: sending incremental file list sent 2046 bytes received 13 bytes 4118.00 bytes/sec total size is 1976832 speedup is 960.09 spawn rsync -avH --delete /home/dwetl/perl_script dwetl@10.128.8.151:/home/dwetl/perl_script dwetl@10.128.8.151's password: sending incremental file list sent 22952 bytes received 26 bytes 15318.67 bytes/sec total size is 746771078 speedup is 32499.39 ################################################################################################# expect: spawn id exp4 not open while executing "expect "*"" 原因:10.128.8.151上配置了SSH 用户等效性 移走即可 查到了一个明确的解释:Figured out why. I had generated ssh keys and copied it on to the destination machine. So there was no "Password: " prompt. Hence before send could complete, the ssh connection had closed. I deleted the ssh keys from the destination machine and ran the script again and observed no issues.(解释链接:http://stackoverflow.com/questions/1387848/issues-with-expect-send-spawn-id-exp4-not-open)