Skip to content

Instantly share code, notes, and snippets.

Created May 28, 2020 19:19
What would you like to do?
Is a device currently up on LAN (determine if my phone is at home).
use strict;
use warnings;
use Net::Ping;
my $file = "/tmp/amihome";
my $host = "";
my $current;
if ( -r $file ) {
open( my $in, '<', $file ) || die "Can't open existing file\n";
while (<$in>) {
$current = $_;
my $p = Net::Ping->new();
my $new = $p->ping($host);
print $new . "\n";
unless (defined($current) && $current == $new) {
open( my $out, '>', $file ) || die "Can't open output file\n";
print $out $new;
close $out;
# Copy to server
`scp -i /root/.ssh/no_pass /tmp/amihome jpm\@`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment