X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=install%2F5.005%2FNet-Whois-Raw%2Fpwhois;fp=install%2F5.005%2FNet-Whois-Raw%2Fpwhois;h=56d9a7e8d0504bf0b34c6dff12f92cc59e1b6aec;hp=0000000000000000000000000000000000000000;hb=35effa1bf4ac902547615c816960bbc8db8e7256;hpb=de16528011da925274ae502e928c7878bbd7fefa diff --git a/install/5.005/Net-Whois-Raw/pwhois b/install/5.005/Net-Whois-Raw/pwhois new file mode 100755 index 000000000..56d9a7e8d --- /dev/null +++ b/install/5.005/Net-Whois-Raw/pwhois @@ -0,0 +1,106 @@ +#!/usr/bin/perl -w + +use Net::Whois::Raw qw( whois $OMIT_MSG $CHECK_FAIL $TIMEOUT $CACHE_DIR ); +use Getopt::Std; +use strict; +use vars qw($opt_s $opt_c $opt_S $opt_C $opt_t $opt_T $opt_h); + +getopts("scSCtT:h"); + +if ($opt_h) { + print < ] [ -T] [ ] + +The -s switch attempts to strip the copyright message or disclaimer. +The -S switch will attempt some exra rules for it. +The -c switch attempts to return an empty answer for failed searches. +The -C switch will attempt some exra rules for it. +The -T switch takes a parameter that is used for the timeout for +connection attempts. +The -t switch enables caching. +EOM + exit; +} + + +$OMIT_MSG = $CHECK_FAIL = 0; + +$OMIT_MSG = 1 if $opt_s; +$OMIT_MSG = 2 if $opt_S; +$CHECK_FAIL = 1 if $opt_c; +$CHECK_FAIL = 2 if $opt_C; +$TIMEOUT = $opt_T; + +$CACHE_DIR = undef; +if ($opt_t) { + if ($^O =~ /Win/) { + $CACHE_DIR = $ENV{'TEMP'} || "C:\\temp"; + } else { + $CACHE_DIR = $ENV{'TEMP'} || "/tmp"; + my @ent = getpwuid($>); + if (@ent) { + foreach ("/tmp/$ent[0]", "$ent[7]/.pwhois") { + mkdir $_, 0644; + if (open(O, ">$_/__$$-$$.tmp")) { + close(O); + unlink "$_/__$$-$$.tmp"; + $CACHE_DIR = $_; + last; + } + } + } + } +} + +my $dom = $ARGV[0] || die "Usage: $0 domain"; + +my $server = $ARGV[1]; + +eval { + my $result = whois($dom, $server); + if ($result) { + print $result; + } else { + print STDERR "Failed.\n"; + } +}; +if ($@) { + my $err = $@; + $err =~ s/\s+at \S+ line \d+\.$//; + print "\nWhois information could not be fetched:\n$err\n"; + exit -1; +} + +__END__ + +=head1 NAME + +pwhois - Perl written whois client + +=head1 SYNOPSIS + + pwhois perl.com + pwhois gnu.org + pwhois -s police.co.il + pwhois -c there.is.no.tld.called.foobar + pwhois yahoo.com whois.networksolutions.com + pwhois -T 10 funet.fi + +etc etc..... + +=head1 DESCRIPTION + +Just invoke with a domain name, optionally with a whois server name. +The B<-s> switch attempts to strip the copyright message or disclaimer. +The B<-c> switch attempts to return an empty answer for failed searches. +The B<-T> switch takes a parameter that is used for the timeout for +connection attempts. + +=head1 AUTHOR + +Ariel Brosh, B + +=head1 SEE ALSO + +L. +