< Concord
Content added Content deleted
No edit summary |
imported>mutante mNo edit summary |
||
(9 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
this is a nice basic script that uses oracle's sql to get the element names that have a matching [[IP]] address. |
|||
[http://www.excce.com 中国涂装设备网][http://www.hzn.cn/web/ 网站建设�?�州][http://www.hzn.cn/domain/ �?�州域�??注册][http://www.hzn.cn/email/ �?�州�?业邮局][http://www.hzn.cn/tj/ �?�州网站网络推广][http://www.51122.com/coating/ 涂装] |
|||
<code> |
|||
[http://www.51122.com 世纪网�?�之家] |
|||
# more getNamefromIP.pl |
|||
[http://go.excce.com 网站建设] |
|||
#!/bin/perl |
|||
[http://www.uusky.com 世纪情感] |
|||
use strict; |
|||
[http://www.uusky.org �?�州网络公�?�] |
|||
use warnings; |
|||
[http://www.uusky.net �?�州喷塑加工] |
|||
# simple script that outputs the names of elements that have an IPaddress given as and argument |
|||
# added in a simple IP address test (NOTE this is not a full IPV4 test ie it will alow 333.x.x.x) |
|||
# but we wont worry about that as its only querying a database and will just retuirn no values |
|||
# if not found. usage 'getNamefromIP.pl x.x.x.x' |
|||
[http://www.hzn.cn �?�州网站建设] |
|||
my $oraUser="user name here"; |
|||
[http://www.hzn.cn �?�州网络公�?�] |
|||
my $oraPassword="password here"; |
|||
[http://www.uusky.com/ 情感] |
|||
my $oraPath="path to sqlplus command here"; # eg "/oracle/bin" |
|||
[http://www.uusky.org �?�州网站建设] |
|||
my $ipAddress=$ARGV[0] || die "Missing args $!"; # get ipAddress |
|||
[http://www.znpp.com �?�州网站建设] |
|||
if ($ipAddress !~ /^(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})$/) {die "not a valid 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\.$/; |
|||
next if /no rows selected/; |
|||
print "$segment\n"; |
|||
} |
|||
</code> |
|||
related: [[Perl]] |
|||
[[Concord|Back to Concord Index]] |
|||
[http://uusky.zj.com �?�州网站建设] |
|||
[http://sdxx.zj.com �?�州网络公�?�] |
|||
[http://www.loveday.somee.com/ GOOGLE排�??] |
|||
[http://www.cnzjqi.somee.com 网站建设] |
|||
[http://www.uusky.com/host 网站建设] |
|||
[http://www.uusky.com/webpage/ 网站建设] |
|||
[http://www.uusky.com/inf/ 网站建设] |
|||
[http://www.hzjl365.com/inc/ 网站建设] |
|||
[http://xnan2.91x.net/ 网站建设] |
|||
[http://www.xinyifang.net/inf/ 网站建设] |
|||
[http://web.uusky.org/ 网站建设] |
|||
[http://www.pagerealm.com/agent2732/ 网站建设] |
|||
[http://www.pcpages.com/uusky/ 网站建设] |
|||
[http://www.coolgoose.com/sites/xnane/ 网站建设] |
|||
[http://www.coolgoose.com/sites/xnane/web/ 网站建设] |
|||
[http://www.coolgoose.com/sites/xnane/company/ 网络公�?�] |
|||
[http://www.znpp.com/google/ 网络公�?�] |
|||
[http://uusky.zj.com/company/ 网络公�?�] |
|||
[http://uusky.zj.com/web/ 网络公�?�] |
|||
[http://www.blogcn.com/user20/xnan2 网站建设] |
|||
[http://xnan2.blogdriver.com/xnan2/ 网站建设] |
|||
[[Category:Concord]] |
|||
[http://www.loveday.epsystem.net 网站建设] |
|||
[[Category:Computer]] |
|||
[http://diary.51122.com �?费申请个人日记] |
|||
[[Category:English]] |
|||
[http://gb.51122.com �?费申请留言本] |
|||
[[Category:Perl]] |
|||
[http://www.51122.com/website/ �?�州网页设计] |
|||
[http://www.excce.com/website/ �?�州网站设计] |
Latest revision as of 09:18, 10 September 2006
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
# added in a simple IP address test (NOTE this is not a full IPV4 test ie it will alow 333.x.x.x)
# but we wont worry about that as its only querying a database and will just retuirn no values
# if not found. 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
if ($ipAddress !~ /^(d{1,3}).(d{1,3}).(d{1,3}).(d{1,3})$/) {die "not a valid 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\.$/;
next if /no rows selected/;
print "$segment\n";
}
related: Perl