美文网首页
Linux远程自动登录脚本

Linux远程自动登录脚本

作者: 沧海月明猪有泪 | 来源:发表于2018-11-23 09:13 被阅读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

相关文章

网友评论

      本文标题:Linux远程自动登录脚本

      本文链接:https://www.haomeiwen.com/subject/bppdqqtx.html