
SteffenBaier
Novice
Feb 17, 2011, 7:01 AM
Post #1 of 3
(818 views)
|
|
[solved] Socket issue / Can't use an undefined value as a symbol reference
|
Can't Post
|
|
If I run below Perl script it fails after the Socket cannot connect / timeout to a device. Can't use an undefined value as a symbol reference at test.pl line 41 #!/usr/bin/perl -w #rebootutility.pl,v 0.98 2011/02/16 Steffen Baier $ use Socket; use IO::Socket; use strict; use warnings; ##################################### # Netmask 255.255.255.0 = 0xFFFFFF00# # Netmask 255.255.0.0 = 0xFFFF0000# # Netmask 255.0.0.0 = 0xFF000000# # Netmask 0.0.0.0 = 0x00000000# ##################################### my $netmask = 0xFFFFFF00; # 255.255.255.0 my $start_address = unpack 'N', inet_aton( '10.252.75.1' ); my $finish_address = unpack 'N', inet_aton( '10.252.75.254' ); for ( my $address = $start_address; $address <= $finish_address; ++$address ) { next if ( $address & $netmask ) == $address or ( $address & ~$netmask ) == ~$netmask; print inet_ntoa( pack 'N', $address); print "\n"; my $destination = inet_ntoa( pack 'N', $address); my $socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$destination", PeerPort => "80", Timeout => "2", ); if ($@) { print "Failed,Could not connect!\n"; } else { print "Passed,connected successfully.\n"; } print $socket "GET $destination/reg_1.htm HTTP/1.1\r\nAuthorization: Basic\r\n\r\n"; } Above script basically sends a HTTP GET request to devices. It incriments the IP Address of the defined Range and should not stop if it cannot reach a device .... Any Idea where I go wrong ..? I used 2x different Perl scripts combined to archive above ..
(This post was edited by SteffenBaier on Feb 17, 2011, 8:43 AM)
|