zoukankan      html  css  js  c++  java
  • 免密登录脚本expect

    1.下载命令expect

    [root@m01 /shell4]# yum install -y expect

    2.编写脚本

    [root@m01 /shell4]# vim expect.sh
    #!/usr/bin/env expect
    
    #开启一个程序
    spawn ssh 172.16.1.7
    #捕获相关内容
    expect {
            "(yes/no)?" { send "yes
    ";exp_continue }
            "password:" { send "123456
    " }
    }
    interact

    也可以这样写

    [root@m01 /shell4]# vim expect.sh
    #!/usr/bin/env expect
    set ip 172.16.1.7
    set pass 123456
    set timeout 5
    #开启一个程序
    spawn ssh $ip
    #捕获相关内容
    expect {
            "(yes/no)?" { send "yes
    ";exp_continue }
            "password:" { send "$pass 
    " }
    }
    interact

  • 相关阅读:
    tzselect
    tzfile
    ttytype
    tty
    TRUNCATE
    true
    troff
    touch
    Open vSwitch
    Web 在线文件管理器学习笔记与总结(5)修改文件内容
  • 原文地址:https://www.cnblogs.com/chenlifan/p/13836785.html
Copyright © 2011-2022 走看看