Linux远程自动登录脚本

2018-11-23  本文已影响0人  沧海月明猪有泪
#!/bin/expect 
spawn  scp uranus.jar  test@172.17.4.94:/data/uranus/  
expect "password:"  
send "test@2018\r"  
interact

spawn  scp uranus.jar  test@172.17.4.96:/data/uranus/
expect "password:"
send "test@2018\r"
interact

spawn ssh test@172.17.4.94 "cd /data/uranus/;sh run.sh restart"
expect "password:"
send "test@2018\r"
interact

spawn ssh test@172.17.4.96 "cd /data/uranus/;sh run.sh restart"
expect "password:"
send "test@2018\r"
interact 

假设文件名称问t.sh,运行此文件命令expect t.sh。服务器必须安装expect

上一篇 下一篇

猜你喜欢

热点阅读