需求描述:  
将10.10.50.16:/home/build下的debug.tcl, good.tcl best.tcl 远程拷贝到10.10.51.16:/home/build下。
实现方法:
1)、将debug.tcl, good.tcl best.tcl 分行写入到filename中
 
2)、在shell/ target=_blank class=infotextkey>shell脚本中调用expect实现远程拷贝:
 
#!/bin/sh
for _item in `cat filename | grep -v '#'`;do
    expect -c "
    set timeout 60
    spawn scp $_item 10.10.51.16:/home/build
    expect {
        "*yes/no*" {send "yesr"}
        "*assword:" {send "buildr"}
    }
    expect eof
    "
    echo "$_item is ok..."
done;
注意:
运行以上shell脚本,需要正确安装了expect模块扩展才可以。