zoukankan      html  css  js  c++  java
  • 远程操作局域网中的主机

    我想把办公室的开发机通过映射实现在家远程访问。由于动态ip可能重启后变化,让linux自动发微博或者email通知我。
    获取广域网的方法:

    curl -s 'http://checkip.dyndns.org' | sed 's/.*Current IP Address: \([0-9\.]*\).*/\1/g'
    curl -s http://www.3322.org/dyndns/getip 这个也行

    采用定时发不是很科学。所以还需要设置触发条件,我希望的是在重启了路由器的时候发送,这种情况的表现是——会断网。
    能否判断网络重新连接后触发,另一种情况是可能会断电,节假日关机等情况。我希望是开机后马上触发。先有个思路,后面看怎么做。

    -----------------------------------------------------------------------------------

    补充:
    刚学shell,用shell写了个发送微博的脚本

    #! /bin/sh
    username=您的sina微博账号
    password=您的密码
    app_key=sina应用的app_key
    realip=`curl -s http://www.3322.org/dyndns/getip`
    nowtime=`date`
    curl -u $username:$password -d "source=$app_key&status=$realip $nowtime" https://api.weibo.com/2/statuses/update.json

    结果如下:

    为了简便ip不发生变化时候不需要发送微博,修改脚本如下:

    #! /bin/sh
    username=用户名
    password=密码
    app_key=APP KEY
    realip=`curl -s http://www.3322.org/dyndns/getip`
    previp=`cat ip.txt`
    
    if [ $previp != $realip ]; then
            echo $realip > ip.txt
            nowtime=`date`
            curl -u $username:$password -d "source=$app_key&status=$realip $nowtime" https://api.weibo.com/2/statuses/update.json
    fi

    然后只需要设置成定时发送就行了。

  • 相关阅读:
    中医手诊原理
    半月痕
    0020 教您新手修车的五种实用技巧
    下面说说我开车12年来的一些心得
    创建电子邮件信纸
    交通事故责任划分2011版(图解)
    育儿语录
    汽车中控台那些按钮是什么用的?
    我的书中的部分函数
    纠结的书名
  • 原文地址:https://www.cnblogs.com/ikodota/p/2834576.html
Copyright © 2011-2022 走看看