#!C:\perl\bin\perl.exe my $netstat = "C:\\WINDOWS\\System32\\netstat.exe"; my $RAdminPort = "4899"; open(NETSTAT, "$netstat -an -p tcp|") or die "Couldn't run netstat - $!\n"; while() { next unless $_ =~ /TCP/; my $line = $_; $line =~ s/\s+//; my ($protocol, $local, $remote, $status) = split(/\s+/, $line, 4); my ($localAddress, $localPort) = split(/:/, $local); if (($localPort eq $RAdminPort) && ($status eq "ESTABLISHED")) { print "Discovered connection to RAdmin from $remote\n"; # Do something here....... } } close(NETSTAT);