in reply to Ping Script Error running on 64bit server

jlandrig:

The error:

Use of uninitialized value in split at script/ping2.pl line 74, <IN> line 17

Indicates that $NBTResults[0] is undefined. That probably means that the $NBTResults string just consisted of newlines. In that event, split would return nothing, so $NBTResults[0] would be undefined. That probably leads to the next two errors.

I'd suggest checking for that and skipping processing when that occurs by putting something like:

next unless @NBTResults;

just before line 74.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Ping Script Error running on 64bit server
by jlandrig (Initiate) on Nov 17, 2017 at 18:07 UTC
    Since the code is designed to display the Nbtstat-a value if it does not match the host file. skipping would work but unfortunatly the script is no longer displaying if the Host is pingable or not output just reads
    Hostname,IP,Alive,NBTHost,Port 55081 ComputerName,IP,Unknown status,,Closed
    But it should have reported computername,IP,YES,,CLOSED this is only happening when we run the script from a Windows 64 bit OS.

      Try running a simplified version of the script and print the responses

      #!/usr/bin/env perl use warnings; use strict; my $serverlist = 'srvlst.txt'; open IN, '<',$serverlist or die "Run aborted. Cannot open endpoint list file ($serverlist)"; while (my $HOST = <IN>) { chomp $HOST; print "Pinging $HOST\n"; my $PingReply = `PING -n 1 -w 1 $HOST`; print "[$PingReply]\n"; if ($PingReply =~ /Reply from/) { my @Temp = split / /, $PingReply; my $IP = $Temp[2]; $IP =~ s/\[//g; $IP =~ s/\]//g; print "IP = [$IP]\n"; my $NBTResults = `nbtstat -a $IP | find \"UNIQUE\"`; print "nbtstat result [$NBTResults]\n"; } }
      poj