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

来源:互联网 发布:icp备案后怎么使用域名 编辑:程序博客网 时间:2024/06/05 10:37
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;"
0 0
原创粉丝点击