Concord/GetNamefromIP

this is a nice basic script that uses oracle's sql to get the element names that have a matching IP address.

use strict; use warnings;
 * # more getNamefromIP.pl
 * 1) !/bin/perl
 * 1) simple script that outputs the names of elements that have an IPaddress given as and argument
 * 2) usage 'getNamefromIP.pl x.x.x.x'

my $oraUser="user name here"; my $oraPassword="password here"; my $oraPath="path to sqlplus command here"; # eg "/oracle/bin" my $ipAddress=$ARGV[0] || die "Missing args $!";      # get  ipAddress

my $elements = qx{$oraPath/sqlplus -S $oraUser/$oraPassword <<EOF set head off SELECT NAME from NH_ELEMENT where IP_ADDRESS='$ipAddress'; exit EOF };

foreach my $segment (split(/ /,$elements)) { next if /^$/; next if /rows selected.$/; print "$segment "; }