Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tlug: another ip-up script



Since I found that "dig -x xxx.xxx.xxx.xxx" does not always answer PTR 
infomation, the following is the one which does not use dig.

 >> #!/usr/bin/perl
 >> require 'sys/socket.ph';
 >> my  $name, $rest,$first ,$localip, $date;
 >> shift;
 >> shift;
 >> $localip=shift;
 >> $name = pack('C4',split(/\./, $localip));
 >> ($name,$rest) = gethostbyaddr($name,&AF_INET);
 >> $first = $name;
 >> $first =~ s/([^\.]+\.[^\.]+\.[^\.]+).*/$1/;
 >> if(open(FILE,"date |")) {
 >>         while(<FILE>) {
 >>                 chop;
 >>                 $date = $_;
 >>         }
 >>         close(FILE);
 >> }
 >> 
 >> if($name) {
 >>         if(open(FILE,">>/etc/hosts")) {
 >>                 print FILE "$localip    $name   $first  # $date\n";
 >>                 close(FILE);
 >>                 system "hostname $first";
 >>         }
 >> }
--------------------------------------------------------------
Next Meeting: 8 August, Tokyo Station Yaesu central gate 12:30
featuring Linux on multiple platforms:
i386, Sparc, PA-Risc, Amiga, SGI, Alpha, PalmPilot, ...
Next Nomikai: 18 September, 19:30 Tengu TokyoEkiMae 03-3275-3691
--------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links