#!/usr/bin/perl

use Net::Ping;

$hostname = '66.123.213.65';
$result = system("ping -c 5 $hostname > /dev/null");
unless($result == 0){ 
  print "disconnected\n";
  system("ssh greenfly\@boxer br --port \/dev\/ttyS0 A4 OFF");
  sleep 1;
  system("ssh greenfly\@boxer br --port \/dev\/ttyS0 A4 OFF");
  sleep 4;
  system("ssh greenfly\@boxer br --port \/dev\/ttyS0 A4 ON");
  sleep 1;
  system("ssh greenfly\@boxer br --port \/dev\/ttyS0 A4 ON");
  print "reconnected\n";
  }
