您的位置:首页 > 运维架构 > Shell

Shell脚本实现自动登录

2017-09-27 23:19 946 查看
#!/usr/bin/expect
spawn ssh hdp34
expect "~"
send "ambari-server sync-ldap --all\r"
expect "*login:"
send "admin\r"
expect "*password:"
send "admind2322\r"
interact

注意上面如果在(ssh hdp34已实现免密登录)
spawn ssh hdp34
expect "~"
这里一开始"~" 输入的是 * 号。因而出现了下面命令输入全部出现输入顺序错误
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  shell