LoginSignup
7
7

More than 5 years have passed since last update.

WiMAXの工事情報をメールで通知するスクリプト

Posted at

WiMAX(UQ)はしばしば工事等で利用できないことがあるわけですが、当日に現地で通信できないと工事情報がホームページに掲載されていても確認のしようがありません。

また、ホームページの工事情報一覧はたくさんの地域が掲載されているので、自分の地域をその中から検索するのも一苦労です。

そこで、事前に工事情報を通知できないかということで、以下のようなスクリプトを作ってレンタルサーバのcronで動作させています。

ご利用の際は地名とメールアドレスの変更が必要です。

check_wimax.pl
#!/usr/bin/perl -w

my @data = `wget -O - http://www.uqwimax.jp/service/information/kouji/data_maintenance.json`;
my $send = 0;

$ENV{'LC_CTYPE'} = "ja_JP.UTF-8";

my @msg = ();

while(my $line = shift @data){
    if($line =~ /(新木場)/){
       $send = $1;
       while($line =~ s/<\w+.*?>// || $line =~ s/<\/\w+>//){
       }
       push(@msg, $line);
    }
}

if($send){
    open(MAIL, '|mail -s "WiMAX stops" abc@def.xyz.ne.jp');
    print MAIL "WiMAX stop at ", $send, "\n";
    print MAIL "see detail at : \n\t\thttp://www.uqwimax.jp/service/information/kouji/  \n";
    print MAIL "-----\n";
    foreach my $msg (@msg){
        print MAIL $msg, "\n";
    }
    print MAIL ".";
    close(MAIL);
}
7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7