< Concord
Content added Content deleted
imported>mutante m (despam) |
imported>DrOwl (UpDate| added in "!split on " and changed var type for segment to $ from %) |
||
Line 14:
my $ipAddress=$ARGV[0] || die "Missing args $!"; # get ipAddress
my
set head off
SELECT NAME from NH_ELEMENT where IP_ADDRESS='$ipAddress';
Line 20:
EOF };
foreach
/,$elements)) {
next if /^$/;
/;▼
next if /rows selected.$/;
print "$
}</pre>
|
Revision as of 12:09, 13 January 2005
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 my $segment (split(/ /,$elements)) {
next if /^$/; next if /rows selected.$/; print "$segment
";
}