1: #!/usr/bin/perl
2: use warnings;
3: use Net::Ping;
4: use Socket;
5:
6: print "Enter the subnet you wish to scan just the first 3 octet's\n";
7: $ipnumber =<STDIN>;
8: chomp $ipnumber;
9: @iparray = map $ipnumber. ".$_",1..254 ;
10: #print @iparray;
11: #open (ERRORLOG, ">errorlog");
12: open (OFFLINE,">offline");
13: #open (ONLINE,">online");
14:
15: #my @iparray = qw( www.slashdot.org www.deja.com www.perlmonks.org );
16:
17:
18: my $proto = 'icmp';
19: my $def_timeout = '0';
20: my $bytes = '64';
21:
22: my $p = Net::Ping->new($proto, $def_timeout , $bytes);
23: $! = 1;
24: foreach my $host (@iparray) {
25: print ONLINE "$host online \n" if $p->ping($host);
26: print ERRORLOG "$host offline \n" unless $p->ping($host,1);
27: print OFFLINE "$host \n" unless $p->ping($host,1);
28: }
29: $p->close();
30: close OFFLINE;
31: close ERRORLOG;
32: close ONLINE;
33:
34: open (IPLIST, "offline");
35: #open (OFFLINEHOST, ">offlinehost");
36: @list=<IPLIST>;
37: $list = @list;
38: #print "@list\n";
39: chomp @list;
40: my $i;
41: my $peer_host;
42: format STDOUT_TOP =
43: IP# Machine name
44: ---------------- ------------------------------------ -------
45: .
46: format STDOUT =
47: @<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^<<<<<<
48: $i, $peer_host, "offline"
49: .
50: foreach $i (@list) {
51: $peer_host = gethostbyaddr(inet_aton($i), AF_INET);
52: #$peer_host = gethostbyaddr(inet_aton($i), AF_INET);
53: #print OFFLINEHOST "$peer_host and ipaddress $i\n";
54: #print OFFLINEHOST "$peer_host and ipaddress $i\n";
55: write
56: }
57: close OFFLINE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pingger Script4
by Chmrr (Vicar) on Apr 26, 2001 at 07:03 UTC | |
|
Re: Pingger Script4
by grinder (Bishop) on Apr 26, 2001 at 11:31 UTC | |
|
Re: Pingger Script4
by Clownburner (Monk) on Apr 26, 2001 at 07:39 UTC |