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

linux shell脚本登录远程执行命令,交互通过脚本

2015-10-22 16:17 477 查看
expect -c "

   set timeout 15

   spawn ssh root@172.16.17.34

   expect *password* { send ××××××\r }

   expect \"]#\"

   send \"cd /\r\"

   send \"tar jxvf name.tar.bz2\r\"

   expect \"]#\"

   send \"cd /name/cswap\r\"

   send \"./stop-all.sh\r\"

   expect \"]#\"

   send \"./start-all.sh\r\"

   expect \"*]#*\"

   send \"exit\r\"

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