expect_安装及脚本写法

yum install tcl-devel
yum install expect

参考代码  写法一定要标准 否则报错

#!/usr/bin/expect
spawn scp /maqingbin/3_ZmData.sql [email protected]:/maqingbin/expectTest
expect {
        "*(yes/no)" {
                send "yes\n"
                expect "password:" { send "xxxpasswordxxx\r"}
        }
        "password:" {
                send "xxxpasswordxxx\r"
        }
}
expect eof
exit

猜你喜欢

转载自blog.csdn.net/maqingbin8888/article/details/82879301