Linux远程自动登录脚本

#!/bin/expect 
spawn  scp uranus.jar  [email protected]:/data/uranus/  
expect "password:"  
send "test@2018\r"  
interact

spawn  scp uranus.jar  [email protected]:/data/uranus/
expect "password:"
send "test@2018\r"
interact

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

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

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

你可能感兴趣的:(Linux远程自动登录脚本)