Google is leaving… Here’s a shell script to monitor that.

Google正要离开中国。

计划今天晚上去来福士16楼为Google献上一束鲜花。

Audio clip: Adobe Flash Player (version 9 or above) is required to play this audio clip. Download the latest version here. You also need to have JavaScript enabled in your browser.

Flowers for Google

此外,还特意写了一个bash脚本来记录下这一切。以一个程序员的方法来纪念。

#!/bin/bash
export PATH="/bin:/usr/bin"

LOG=~/google.log
TMP=/tmp/google.index.html
FMT="+%Y-%m-%d %H:%M:%S"
HOST=www.g.cn
NS=202.96.209.5

while [ 1 ]
do
  date "$FMT" | tee -a $LOG
  ips=`dig @$NS $HOST | sed -n -r 's/^.*IN\s+A\s+(.*)$/\1/p'`
  if [ -n "$ips" ]
  then
    for ip in $ips
    do
      wget -O $TMP $ip > /dev/null 2> /dev/null
      google=`cat $TMP | sed -n -r "s/^.*Google.*$/OK/p" \
        | sed -n -r '1p'`
      if [ -n "$google" ]
      then
        echo "$ip OK" | tee -a $LOG
      else
        echo "$ip ERROR" | tee -a $LOG
      fi
    done
  else
    echo "Can't resolve the host: $HOST" | tee -a $LOG
  fi
  sleep 2
done

Updated on 15th Jan 2010:
升级了一下脚本,使得: 1.通过反向解析检测Google是否遭到域名劫持; 2. 支持同时检测多个Google旗下的域名.

#!/bin/bash
export PATH="/bin:/usr/bin"

LOG=~/google.log
TMP=/tmp/google.index.html
FMT="+%Y-%m-%d %H:%M:%S"
GOOGLE_DOMAINS=("www.g.cn" "www.google.cn" "www.google.com")
NS=202.96.209.5

while [ 1 ]
do
  date "$FMT" | tee -a $LOG
  for domain in ${GOOGLE_DOMAINS[@]}
  do
    echo $domain | tee -a $LOG
    ips=`dig @$NS $domain \
      | sed -n -r 's/^.*IN\s+A\s+(.*)$/\1/p'`
    if [ -n "$ips" ]
    then
      for ip in $ips
      do
        server=`nslookup -q=ptr $ip \
          | sed -n -r 's/^.*name = (.*)$/\1/p'`
        is_server_1e100=`echo $server \
          | sed -n -r 's/^.+\.1e100\.net\./OK/p'`
        if [ "$is_server_1e100" = "OK" ]
        then
          wget -O $TMP $ip > /dev/null 2> /dev/null
          is_google=`cat $TMP \
            | sed -n -r "s/^.*Google.*$/OK/p" | sed -n -r '1p'`
          if [ -n "$is_google" ]
          then
              echo "$ip OK" | tee -a $LOG
          else
              echo "$ip ERROR: NOT GOOGLE PAGE" | tee -a $LOG
          fi
        else
          echo "$ip ERROR: DONAME HIJACK" | tee -a $LOG
        fi
      done
    else
      echo "ERROR: STOP RESOLVE: $domain" | tee -a $LOG
    fi
  done
  echo "" | tee -a $LOG
  sleep 2
done

on January 13th, 2010 | No Comments »

Notice : The music in the above article is offered just for trial, and not published under the general license of this blog.

Hotel California

我找到了传说中的Hotel California。就在580 geary street, San Francisco, California。

580-geary-street-san-francisco-ca

感谢Google Maps

on February 11th, 2009 | No Comments »

发现不明物体

翻阅Google Maps,居然在女友公司旁的马路上发现不明物体--两个接近三角形状的不规则白色物体,约有30~50米长,横跨整条马路。暴击查看

on September 17th, 2008 | 2 Comments »

关于Google浏览器

Google出了一款浏览器,想必大家已经知道了。速度还真快,前几天刚听说要出,这就出来了。

  1. 名字很让人好奇,显然和Firefox有些关系。
  2. 安装目录很让人郁闷,不让选择,直接装到Documents and Settings下的Local Settings\Application Data毕竟是一件很奔放的事情,通常只有做小妾的才这么藏着。
  3. 字体效果比Firefox好看,兼容性似乎还不错。
  4. 没弄明白它没有Flash的插件为什么可以放swf……
  5. 资源占有率不稳定。


on September 3rd, 2008 | 1 Comment »