< Concord
this is a nice basic script that uses oracle's sql to get the element names that have a matching IP address.
# more getNamefromIP.pl
- !/bin/perl
use strict; use warnings;
- simple script that outputs the names of elements that have an IPaddress given as and argument
- 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 (%elements) {
next if /^
/;
next if /rows selected.$/; print $_;
}