Connected clients to my WiFi hotspot

2

When I type arp -a I can see connected clients, but I want the same information piped out to kdialog when a new client connects or disconnects.

Is it possible with shell scripting?

Babu Philip

Posted 2014-10-21T07:42:40.560

Reputation: 21

Answers

0

#!/usr/bin/env perl
use File::Temp 'tempfile';
my $command = 'arp -a';
my (undef, $tmp) = tempfile;
while (1) {
    system "$command > $tmp";
    sleep 1;
    my @diff = split "\n", `bash -c "diff -d -U0 $tmp <($command)"`;
    shift @diff; shift @diff; shift @diff; # remove diff header
    my (@join, @left);
    while (my $line = shift @diff) {
        if ($line =~ s/^-//) {
            push @left, $line;
        } elsif ($line =~ s/^\+//) {
            push @join, $line;
        } else {
            warn "found junk line in diff: $line\n";
        }
    }
    if (@join or @left) {
        system "kdialog --passivepopup 'joined: @join\nleft: @left'"
    }
}

daxim

Posted 2014-10-21T07:42:40.560

Reputation: 1 072