I'm writing a scripts that check the TTL of the ping and found the OS. According the TTL - the script should let me know which OS it is : Linux/ Windows or Unix (Hash table)
I'm getting an error on the line where I should use the TTL variable - and take the right value from the hash (%list) :Use of uninitialized value in print at D:\system\perl\os-rec\os-rec5_.pl line 24 , <HANDLE> line 3. Any idea ? #! C:\Perl\bin\perl -w use strict; use warnings; my %list = (60,"linux",61,"linux",62,"linux",63,"linux",64,"linux", 65,"linux",125,"Windows",126,"Windows",127,"Windows",128,"Windows", 250,"Unix",251,"Unix",252,"Unix",253,"Unix",254,"Unix",255,"Unix", 256,"Unix",257,"Unix",258,"Unix",259,"Unix",260,"Unix"); my $path = "hosts.txt" ; my $machine_IP ; my $cmd ; # read machines hosts names List from the txt file c:1.txt and take the TTL data to th e variable: $line open (MACHINES,$path) or die "Couldn't open file for writing"; while ($machine_IP = <MACHINES>) { chomp($machine_IP) ; my $line ; $cmd = "ping $machine_IP"; open(HANDLE,"$cmd|"); while ($line = <HANDLE>) { if("$line" =~ "TTL=") { $line =~ s/.*TTL=//; print "TTL = $line\n"; print $list{"$line"} ; # print "Machine $machine_IP is $list{$line}" ; last; } } } close HANDLE; close MACHINES; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/