×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Concord/GetNamefromIP

    Revision as of 18:17, 11 January 2005 by imported>DrOwl (simple script that outputs the names of elements that have an IPaddress given as and argument)

    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
    1. !/bin/perl

    use strict; use warnings;

    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 (%elements) {

     next if /^
    

    /;

     next if /rows selected.$/;
     print $_;
    

    }

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.