#!/usr/bin/env perl -w # Script --------------------------------------------------------------------- # wakess: Use nmap to wake up and force an update to a site selector. # # $Id: wakess,v 1.1 2008/11/07 19:01:20 jayrfink Exp $ # # $Author: jayrfink $ # $Date: 2008/11/07 19:01:20 $ # $State $ #----------------------------------------------------------------------------- $SIG{'INT' } = 'interrupt'; $SIG{'QUIT'} = 'interrupt'; $SIG{'HUP' } = 'interrupt'; $SIG{'TRAP'} = 'interrupt'; $SIG{'ABRT'} = 'interrupt'; $SIG{'STOP'} = 'interrupt'; use strict; my $nmap_bin = `which nmap`; # Need to have this installed my @iplist; # don't initialize - should be a state of nothing my $interface = "eth0"; # just a guess for most users sub interrupt { my($sig) = @_; die $sig; die; } sub usage { print "usage: $0 [[option][option arg]]\n"; print "usage: $0 [[-i ][-a \"a1 a2...\"]]\n"; print "options:\n"; print " -i Use interface ifname\n"; print " -a \"a1 a2..\" Loop through addresses\n"; print " -u Print usage message and exit\n"; } if (!$nmap_bin) { print "Error: nmap binary not found\n"; exit (1); } while ( my $arg = shift @ARGV ) { $arg =~ s/-//; # toss out the dash if ( $arg eq 'i' ) { $interface = shift @ARGV; } elsif ( $arg eq 'a' ) { @iplist = shift @ARGV; } elsif ( $arg eq 'u' ) { usage(); exit 0; } else { usage(); exit 1; } } chomp($nmap_bin); foreach (@iplist) { system("$nmap_bin -e $interface -S $_"); } exit (0);