X-Git-Url: http://lab.mitty.jp/git/?a=blobdiff_plain;f=bin%2Fwake;fp=bin%2Fwake;h=0000000000000000000000000000000000000000;hb=df4fa7ba97367054d8073e9f9626b28d8936d941;hp=538e100763bc9f34d05bfe1c4a80657504d65d91;hpb=57d3e5400ce51f1881320585b520bc5f88f004ce;p=lab.git diff --git a/bin/wake b/bin/wake deleted file mode 100755 index 538e100..0000000 --- a/bin/wake +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl - -use Cwd qw( realpath ); -use File::Basename qw( fileparse ); - -@cfg = ('.wake', ( (fileparse( realpath($0) ))[1] ) . '.wake'); -$mac = {}; - -$x = '[0-9a-fA-F]'; -$macre = "$x$x:$x$x:$x$x:$x$x:$x$x:$x$x"; -$ipre = "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}"; - -foreach my $cfg (@cfg) { - open(CFG, $cfg); - while () { - next if /^\s*#/; - next if /^\s*$/; - - chomp; - my($host, $hw, $ip) = split; - push @{$mac->{lc($host)}}, { MAC => $hw, IP => $ip }; - } -} - -if (@ARGV) { - foreach $host (@ARGV) { - if ($host =~ /$macre/) { - print qx(wakeonlan $host); - } - elsif (@physical = @{$mac->{lc($host)}}) { - foreach my $mac (@physical) { - if ($mac->{IP}) { - print qx(wakeonlan -i $mac->{IP} $mac->{MAC}); - } - else { - print qx(wakeonlan $mac->{MAC}); - } - } - } - else { - print lc($host) . ": no such host in the list.\n"; - } - } -} -else { - foreach $host (sort keys %$mac) { - $physical = $mac->{lc($host)}; - foreach my $mac (@$physical) { - print "$host -> $mac->{MAC} -> $mac->{IP}\n"; - } - } -} -