#!/usr/bin/perl $count_8090 = 0; $count_local = 0; # netstatの結果をnetstat.datに書き込む system("netstat > netstat.dat"); # netstat.datを開いて読み込む open( DAT, "netstat.dat" ); while ( ) { if ( $_ =~ /8090/ ){ $count_8090++; } if ( $_=~ /192.168.1./ ){ $count_local++; } } close( DAT ); # 8090の接続が2件でローカルの接続が0件の場合はシャットダウンする if ( $count_8090 == 2 ){ if ( $count_local == 0 ){ system("sync"); system("sync"); system("sync"); system("/sbin/halt -p"); } } exit(0);