#!/usr/bin/perl
use strict;
use warnings;

use Getopt::Long;
use Pod::Usage;

use IO::Socket;
use Net::Wake;


my $VERSION = 0.1;

=head1 NAME

'wol.pl' is simple console based script to boot machines!.

=head1 SYNOPSIS

  #to boot a machine.
  wol.pl --mac '<mac-address>'

  #to boot multiple machines.
  wol.pl --mac '<mac-address>' --mac '<mac-address>' --mac '<mac-address>'...

  wol.pl --man for more details.


=head1 DESCRIPTION

`wol.pl` is a simple console based script to boot machines remotely.
It takes n number of mac addresses as arguments and it
gives a boot call to the remote machines in sequence.

Obvisouly, the system that you are trying to boot should have appropriate BIOS settings
to manage this. Set up Wake-on-lan settings appropriately and then use the script. 

=head1 PREREQUISITES

`wol.pl` depends on the following modules:

  - C<IO::Socket>
  - C<Net::Wake>
  - C<Getopt::Long>
  - C<Pod::Usage>

=cut


# Set up defaults
my $verbose = 0;
my $help    = undef;
my $man     = undef;
my @macs;

GetOptions(  'help' => \$help,
              'man' => \$man,
           'macs=s' => \@macs);

pod2usage (-verbose => 2) if $man;
pod2usage (1)             if $help or not @macs;

Net::Wake::by_udp(undef,$macs[$_]) for (0..$#macs);


=head1 AUTHOR

ramki <ramki.s@gmail.com>

=head1 BUGS

Please report to the author.

=head1 SCRIPT CATEGORIES

UNIX/System_administration

Networking

=head1 COPYRIGHT

Copyright 2005 Ramakrishnan S

This program is free software; you can redistribute it and/or modify it under
 the same terms as Perl itself.
