您的位置:首页 > 运维架构 > Shell

shell 执行expect

2015-10-30 11:29 190 查看
<pre name="code" class="sql">#!/bin/bash
passwd='1234567'
/usr/bin/expect<<EOF
set time 30
spawn scp 1.sh  root@192.168.32.65:/root
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}
expect eof
EOF

/usr/bin/expect<<EOF
spawn ssh  root@192.168.32.65
expect {
"*yes/no" { send "yes\r"; exp_continue }
"*password:" { send "$passwd\r" }
}

expect "*#"
send "who\r"
expect "*#"
send "date\r"
expect "*#"
send "exit\r"
interact
expect eof
EOF




                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: