zoukankan      html  css  js  c++  java
  • expect实战

    1、测试主机是否在线

    #!/bin/bash
    #创建一个IP地址文件。
    >ip.txt   (清空文本)
    #使用for循环ping测试主机是否在线。
    for i in {2..254}
    do
            {
    #学员请注意练习环境的IP地址,可能与示例中不同。
            ip=192.168.122.$i
            ping -c1 -W1 $ip &> /dev/null
            if [ $? -eq 0 ];then
            echo "$ip" >> ip.txt

            /usr/bin/expect <<-EOF    (使得expect能在shell里运行)
    set timeout 10
    spawn ssh-copy-id $ip
    expect {
            "yes/no" { send "yes "; exp_continue }
            "password:" { send "centos " }
    }
    expect   eof
    EOF
            fi
            }&
    done
    wait
    echo "finishi..."

  • 相关阅读:
    使用springboot2+elasticsearch7注意事项
    jwt使用
    CTF web之旅 15
    CTF web之旅 14
    CTF web之旅 13
    CTF web之旅 12
    CTF web之旅 11
    CTF web之旅 10
    CTF web之旅 9
    CTF web之旅 8
  • 原文地址:https://www.cnblogs.com/zjz20/p/11354552.html
Copyright © 2011-2022 走看看