美文网首页
shell自动登录

shell自动登录

作者: yahzon | 来源:发表于2018-04-26 15:41 被阅读2次
    #!/bin/bash
    
    uname=tanghongfei
    passwd=123456    
    
    pass2=`echo -n $passwd | md5sum | cut -c9-24`
    
    curl -H "Content-Type:application/x-www-form-urlencoded" -d "username=$uname&password=$pass2&drop=0&type=1&n=100" http://xxx.xxx.xxx.xxx/cgi-bin/do_login 2>/dev/null | grep error
    
    if [ "$?" -eq "0" ]; then
      exit -1
    fi
    
    exit 0
    

    监控是否掉线

    #! /bin/sh
    
    interval=10
    
    while (true)
    do
        result=`ping -w $interval www.baidu.com | grep '0 received'`
        if [ "$result" != ""  ]; then
            echo "network status: disconnected!!! relogin!!!"
            ./login.sh
        else
            echo "network status: connected!"
            sleep 10
        fi
    done
    

    相关文章

      网友评论

          本文标题:shell自动登录

          本文链接:https://www.haomeiwen.com/subject/khqmlftx.html