在本地机器上远程操控机器做如下操作:执行远程机器上的脚本、传输文件、获取返回值.........
1、expect
如下:
#!/usr/bin/expect -f
set password *******
set ip *******
set addrfrom *********
set addrto *******
#download
spawn scp ${addrfrom} root@${ip}:${addrto}
set timeout 3
expect {
"yes/no" {send "yes\r";exp_continue}
}
set timeout 500
expect
set timeout 3
send "${password}\r"
set timeout 300
send "exit\r"
expect eof
保存为*****.exp;执行以上脚本的命令是:expect
2、ssh
以上也是实现ssh连接,ssh有有需要密码和无密码信任两种远程连接的方法。