【shell】ssh登录到其他主机并切换root运行查询命令

/usr/bin/expect << EOF
spawn /usr/bin/ssh -t -p 22088 -oStrictHostKeyChecking=no sms@${ip} "su "

expect {
"*assword*" { send "Eastcom@!@#\n" }
}

expect {
"Password:" { send "Eastcomnfv@2018\n" }
}

expect "*]#"
send "sh /utxt/soft/ssftp/ssftp_restart.sh \r"
expect "*]#"
send "exit\r"
expect eof

EOF

posted @ 2021-11-04 11:02  新茶煮酒  阅读(636)  评论(0编辑  收藏  举报