亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? psa-chapter05.txt

?? perl語言的經典文章
?? TXT
?? 第 1 頁 / 共 2 頁
字號:
Example code from Perl for System Administration by David N. Blank-Edelman
O'Reilly and Associates, 1st Edition, ISBN 1-56592-609-9

Chapter Five
============
#*
#* one way to parse a host file
#*

open(HOSTS, "/etc/hosts") or die "Unable to open host file:$!\n";
while (defined ($_ = <HOSTS>)) {
    next if /^#/;  # skip comments lines
    next if /^$/;  # skip empty lines
	 s/\s*#.*$//;  # delete in-line comments and preceding whitespace
    ($ip, @names) = split;
	 die "The IP address $ip already seen!\n" if (exists $addrs{$ip});
    $addrs{$ip} = [@names];
    for (@names){
	 die "The host name $_ already seen!\n" if (exists $names{$_});
         $names{$_} = $ip;
    }
}
close(HOSTS);
-------
#*
#* generate a host file from a machine database
#*

$datafile ="./database";
$recordsep = "-=-\n";

open(DATA,$datafile) or die "Unable to open datafile:$!\n";

$/=$recordsep; # prepare to read in database file one record at a time

print "#\n\# host file - GENERATED BY $0\n# DO NOT EDIT BY HAND!\n#\n";
while (<DATA>) {
    chomp;                           # remove the record separator
    # split into key1,value1,...bingo, hash of record
    %record = split /:\s*|\n/m; 
    print "$record{address}\t$record{name} $record{aliases}\n";
}
close(DATA);
-------
#*
#* generate host file from machine database with error checking added
#*

$datafile ="./database";
$recordsep = "-=-\n";

open(DATA,$datafile) or die "Unable to open datafile:$!\n";

$/=$recordsep; # prepare to read in database file one record at a time

print "#\n\# host file - GENERATED BY $0\n# DO NOT EDIT BY HAND!\n#\n";
while (<DATA>) {
    chomp;  # remove the record separator
    # split into key1,value1,...bingo, hash of record
    %record = split /:\s*|\n/m; 

    # check for bad hostnames
    if ($record{name} =~ /[^-.a-zA-Z0-9]/) {
	    warn "!!!! $record{name} has illegal host name characters,
              skipping...\n";
	    next;
    }

    # check for bad aliases
    if ($record{aliases} =~ /[^-.a-zA-Z0-9\s]/) {
	    warn "!!!! $record{name} has illegal alias name characters,
              skipping...\n";
	    next;
    }

    # check for missing address
    if (!$record{address}) {
	    warn "!!!! $record{name} does not have an IP address,
              skipping...\n";
	    next;
    }

    # check for duplicate address
    if (defined $addrs{$record{address}}) {
	    warn "!!!! Duplicate IP addr: $record{name} &
              $addrs{$record{address}}, skipping...\n";
	    next;
    }
    else {
	    $addrs{$record{address}} = $record{name};
    }

    print "$record{address}\t$record{name} $record{aliases}\n";
}
close(DATA);
-------
#*
#* generating host file from machine database with prettier output
#*
$datafile ="./database";

# get username on either WinNT/2000 or UNIX
$user = ($^O eq "MSWin32")? $ENV{USERNAME} :
                            (getpwuid($<))[6]." (".(getpwuid($<))[0].")";

open(DATA,$datafile) or die "Unable to open datafile:$!\n";

$/=$recordsep; # read in database file one record at a time

while (<DATA>) {
    chomp;                           # remove the record separator
    # split into key1,value1
    @record = split /:\s*|\n/m; 

    $record ={};                     # create a reference to empty hash
    %{$record} = @record;            # populate that hash with @record

    # check for bad hostname
    if ($record->{name} =~ /[^-.a-zA-Z0-9]/) {
	    warn "!!!! ".$record->{name} .
                 " has illegal host name characters, skipping...\n";
	    next;
    }

    # check for bad aliases
    if ($record->{aliases} =~ /[^-.a-zA-Z0-9\s]/) {
	    warn "!!!! ".$record->{name} .
                 " has illegal alias name characters, skipping...\n";
	    next;
    }

    # check for missing address
    if (!$record->{address}) {
	    warn "!!!! ".$record->{name} .
             " does not have an IP address, skipping...\n";
	    next;
    }

    # check for duplicate address
    if (defined $addrs{$record->{address}}) {
	    warn "!!!! Duplicate IP addr:".$record->{name}.
                 " & ".$addrs{$record->{address}}.", skipping...\n";
	    next;
    }
    else {
	    $addrs{$record->{address}} = $record->{name};
    }

    $entries{$record->{name}} = $record; # add this to a hash of hashes
}
close(DATA);

# print a nice header
print "#\n\# host file - GENERATED BY $0\n# DO NOT EDIT BY HAND!\n#\n";
print "# Converted by $user on ".scalar(localtime)."\n#\n";

# count the number of entries in each department and then report on it
foreach my $entry (keys %entries){
    $depts{$entries{$entry}->{department}}++;
}
foreach my $dept (keys %depts) {
    print "# number of hosts in the $dept department: $depts{$dept}.\n";
}
print "# total number of hosts: ".scalar(keys %entries)."\n#\n\n";

# iterate through the hosts, printing a nice comment and the entry itself
foreach my $entry (sort byaddress keys %entries) {
    print "# Owned by ",$entries{$entry}->{owner}," (",
          $entries{$entry}->{department},"): ",
          $entries{$entry}->{building},"/",
          $entries{$entry}->{room},"\n";
    print $entries{$entry}->{address},"\t",
          $entries{$entry}->{name}," ",
          $entries{$entry}->{aliases},"\n\n";
}

sub byaddress {
   @a = split(/\./,$entries{$a}->{address});
   @b = split(/\./,$entries{$b}->{address});
   ($a[0]<=>$b[0]) ||
   ($a[1]<=>$b[1]) ||
   ($a[2]<=>$b[2]) ||
   ($a[3]<=>$b[3]);
}
-------
#*
#* generating host file from machine database with RCS support added
#*
$outputfile="hosts.$$"; # temporary output file
$target="hosts";        # where we want the converted data stored

$datafile ="./database";

# get username on either WinNT/2000 or UNIX
$user = ($^O eq "MSWin32")? $ENV{USERNAME} :
                            (getpwuid($<))[6]." (".(getpwuid($<))[0].")";

open(DATA,$datafile) or die "Unable to open datafile:$!\n";

$/=$recordsep; # read in database file one record at a time

while (<DATA>) {
    chomp;                           # remove the record separator
    # split into key1,value1
    @record = split /:\s*|\n/m; 

    $record ={};                     # create a reference to empty hash
    %{$record} = @record;            # populate that hash with @record

    # check for bad hostname
    if ($record->{name} =~ /[^-.a-zA-Z0-9]/) {
	warn "!!!! ".$record->{name} .
             " has illegal host name characters, skipping...\n";
	next;
    }

    # check for bad aliases
    if ($record->{aliases} =~ /[^-.a-zA-Z0-9\s]/) {
	warn "!!!! ".$record->{name} .
             " has illegal alias name characters, skipping...\n";
	next;
    }

    # check for missing address
    if (!$record->{address}) {
	warn "!!!! ".$record->{name} .
	     " does not have an IP address, skipping...\n";
	next;
    }

    # check for duplicate address
    if (defined $addrs{$record->{address}}) {
	warn "!!!! Duplicate IP addr:".$record->{name}.
             " & ".$addrs{$record->{address}}.", skipping...\n";
	next;
    }
    else {
	    $addrs{$record->{address}} = $record->{name};
    }

    $entries{$record->{name}} = $record; # add this to a hash of hashes
}
close(DATA);

open(OUTPUT,"> $outputfile") or 
  die "Unable to write to $outputfile:$!\n";

print OUTPUT "#\n\# host file - GENERATED BY $0\n
              # DO NOT EDIT BY HAND!\n#\n";
print OUTPUT "# Converted by $user on ".scalar(localtime)."\n#\n";

# count the number of entries in each department and then report on it
foreach my $entry (keys %entries){
    $depts{$entries{$entry}->{department}}++;
}

foreach my $dept (keys %depts) {
    print OUTPUT "# number of hosts in the $dept department:
                  $depts{$dept}.\n";
}
print OUTPUT "# total number of hosts: ".scalar(keys %entries)."\n#\n\n";

# iterate through the hosts, printing a nice comment and the entry
foreach my $entry (sort byaddress keys %entries) {
    print OUTPUT 
          "# Owned by ",$entries{$entry}->{owner}," (",
          $entries{$entry}->{department},"): ",
          $entries{$entry}->{building},"/",
          $entries{$entry}->{room},"\n";
    print OUTPUT 
          $entries{$entry}->{address},"\t",
          $entries{$entry}->{name}," ",
          $entries{$entry}->{aliases},"\n\n";
}

close(OUTPUT);

use Rcs;
# where our RCS binaries are stored
Rcs->bindir('/usr/local/bin');  
# create a new RCS object
my $rcsobj = Rcs->new;          
# configure it with the name of our target file
$rcsobj->file($target);
# check it out of RCS (must be checked in already)
$rcsobj->co('-l');
# rename our newly created file into place 
rename($outputfile,$target) or 
  die "Unable to rename $outputfile to $target:$!\n";
# check it in
$rcsobj->ci("-u","-m"."Converted by $user on ".scalar(localtime)); 

sub byaddress {
   @a = split(/\./,$entries{$a}->{address});
   @b = split(/\./,$entries{$b}->{address});
   ($a[0]<=>$b[0]) ||
   ($a[1]<=>$b[1]) ||
   ($a[2]<=>$b[2]) ||
   ($a[3]<=>$b[3]);
}
-------
#*
#* print the contents of the NIS hosts map
#*

use Net::NIS;

# get our default NIS domain name
$domain = Net::NIS::yp_get_default_domain(); 
# grab the map
($status, $info) = Net::NIS::yp_all($domain,"hosts.byname"); 
foreach my $name (sort keys %{$info}){
    print "$name => $info->{$name}\n";
}
-------
#*
#* look up the IP address of a particular hostname in NIS
#*

use Net::NIS;

$hostname = "olaf.oog.org";
$domain = Net::NIS::yp_get_default_domain(); 
($status,$info) = Net::NIS::yp_match($domain,"hosts.byname",$hostname);
print $info,"\n";
-------
#*
#* check that all NIS servers are responding properly
#*

use Net::NIS;

$yppollex = "/usr/etc/yp/yppoll"; # full path to the yppoll executable

$domain = Net::NIS::yp_get_default_domain(); 

($status,$info) = Net::NIS::yp_all($domain,"ypservers");

foreach my $name (sort keys %{$info}) {
    $answer = `$yppollex -h $name hosts.byname`;
    if ($answer !~ /has order number/) {
        warn "$name is not responding properly!\n";
    }
}
-------
#*
#* subroutine to generate DNS configuration file header
#*

# get today's date in the form of YYYYMMDD
@localtime = localtime;
$today = sprintf("%04d%02d%02d",$localtime[5]+1900,
                                $localtime[4]+1,
                                $localtime[3]);

# get username on either NT/2000 or UNIX
$user = ($^O eq "MSWin32")? $ENV{USERNAME} :
                            (getpwuid($<))[6]." (".(getpwuid($<))[0].")";

sub GenerateHeader{
    my($header);

    # open old file if possible and read in serial number     
    # assumes the format of the old file
    if (open (OLDZONE,$target)){
	    while (<OLDZONE>) {
	        next unless (/(\d{8}).*serial/); 
	        $oldserial = $1;
	        last;
	    }
	    close (OLDZONE);
    }
    else {
	$oldserial = "000000"; # otherwise, start with a 0 number
    }
    
    # if old serial number was for today, increment last 2 digits, else 
    # start a new number for today
    $olddate = substr($oldserial,0,6);
    $count = (($olddate == $today) ? substr($oldserial,6,2)+1 : 0);

    $serial = sprintf("%6d%02d",$today,$count);

    # begin the header
    $header .= "; dns zone file - GENERATED BY $0\n";
    $header .= "; DO NOT EDIT BY HAND!\n;\n";
    $header .= "; Converted by $user on ".scalar((localtime))."\n;\n";
    
    # count the number of entries in each department and then report
    foreach my $entry (keys %entries){
        $depts{$entries{$entry}->{department}}++;
    }
    foreach my $dept (keys %depts) {
        $header .= "; number of hosts in the $dept department:            
                    $depts{$dept}.\n";
    }
    $header .= "; total number of hosts: ".scalar(keys %entries)."\n;\n\n";

    $header .= <<"EOH";

@ IN SOA   dns.oog.org. hostmaster.oog.org. (
                           $serial ; serial
                            10800    ; refresh
                            3600     ; retry
                            604800   ; expire
                            43200)   ; TTL

@                           IN  NS  dns.oog.org.

EOH

  return $header;
}
-------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕欧美国产| 国产99久久久国产精品潘金| 国产曰批免费观看久久久| 色婷婷精品久久二区二区蜜臀av| 日韩欧美美女一区二区三区| 一区二区三区四区在线播放| 国产v日产∨综合v精品视频| 3d动漫精品啪啪| 一区二区三区欧美激情| 成人三级在线视频| 亚洲精品在线三区| 日韩不卡一区二区三区| 欧美日韩国产高清一区二区 | 成人黄色一级视频| 精品国产露脸精彩对白| 丝袜亚洲另类欧美| 日本黄色一区二区| 亚洲三级在线播放| 99re热这里只有精品免费视频 | 日韩欧美电影一二三| 亚洲国产另类精品专区| 91捆绑美女网站| 中文字幕日本乱码精品影院| 国产美女一区二区三区| 久久色.com| 国产呦精品一区二区三区网站| 精品久久久久久久久久久久久久久久久| 亚洲h动漫在线| 91麻豆精品91久久久久同性| 亚洲超碰精品一区二区| 91精品欧美一区二区三区综合在| 亚洲成人免费在线| 欧美一区午夜精品| 看电视剧不卡顿的网站| 精品国产一区久久| 国产精品一品二品| 国产精品久久久久久久久免费丝袜| 国产盗摄精品一区二区三区在线| 欧美—级在线免费片| jvid福利写真一区二区三区| 中文字幕亚洲视频| 欧美日韩亚洲综合在线| 免费不卡在线观看| 欧美激情一区二区在线| 97se亚洲国产综合自在线观| 日韩美女视频一区二区| 欧美丝袜自拍制服另类| 久久精品国产99国产| 久久久精品国产免大香伊| 99久久国产综合精品女不卡| 亚洲成人在线免费| 久久综合视频网| 91麻豆.com| 日本不卡高清视频| 国产性天天综合网| 色综合咪咪久久| 亚洲v日本v欧美v久久精品| 欧美大片在线观看| 久久成人免费日本黄色| 欧美另类变人与禽xxxxx| 亚洲韩国一区二区三区| 日韩免费电影网站| 国产成人免费视频网站| 亚洲一区二区三区四区五区黄| 欧美一级理论性理论a| 成人一区二区三区在线观看| 天堂一区二区在线| 久久久精品日韩欧美| 欧美日韩国产区一| 精一区二区三区| 亚洲精品v日韩精品| 精品国产a毛片| 在线观看一区日韩| 国产成人综合在线播放| 五月天国产精品| 欧美经典一区二区| 91精品国产综合久久精品app| 粉嫩绯色av一区二区在线观看| 亚洲网友自拍偷拍| 中文字幕精品一区二区精品绿巨人| 欧美色区777第一页| 成人免费福利片| 精品一区二区三区免费观看 | 成人性生交大片免费看中文| 午夜电影网一区| 国产精品色婷婷久久58| 日韩片之四级片| 欧美三级电影精品| jizzjizzjizz欧美| 国内精品第一页| 日韩影院免费视频| 亚洲制服丝袜av| 中文字幕亚洲视频| 国产欧美一区二区三区网站| 精品理论电影在线观看| 欧美日韩精品专区| 欧美性猛交xxxx黑人交| 色哟哟国产精品| 99精品久久只有精品| 成人性生交大片免费看中文网站| 九九国产精品视频| 久久精品国产在热久久| 日本伊人色综合网| 亚洲成a天堂v人片| 亚洲va天堂va国产va久| 一区二区三区免费在线观看| 国产精品久久午夜| 中文字幕免费一区| 国产精品乱码一区二区三区软件 | 欧美一二三在线| 欧美年轻男男videosbes| 欧美性受极品xxxx喷水| 欧美性色欧美a在线播放| 91国产免费观看| 欧美在线观看一区二区| 色综合久久99| 欧美艳星brazzers| 欧美性猛交xxxx乱大交退制版| 色94色欧美sute亚洲线路一ni| 色综合久久久久综合体| 在线看不卡av| 日韩视频免费观看高清完整版 | 亚洲精品中文在线观看| 一区二区三区在线看| 亚洲成av人片在www色猫咪| 亚洲成a人片在线不卡一二三区| 亚洲成a人在线观看| 美女被吸乳得到大胸91| 国产成人丝袜美腿| 91网上在线视频| 欧美日本一道本在线视频| 欧美精品乱人伦久久久久久| 精品少妇一区二区三区| 中文欧美字幕免费| 亚洲与欧洲av电影| 免费看欧美女人艹b| 国产成人av网站| 欧美亚洲动漫制服丝袜| 日韩欧美国产综合一区| 中文天堂在线一区| 天天综合日日夜夜精品| 国内精品伊人久久久久av一坑| 国产成人午夜精品5599 | 91在线你懂得| 在线观看91av| 国产欧美一区二区精品久导航| 中文字幕在线不卡| 免费在线观看精品| kk眼镜猥琐国模调教系列一区二区| 91成人免费在线视频| 精品国产一区二区三区久久影院| 国产精品久久三| 日本欧美一区二区三区乱码| 国产91精品一区二区麻豆网站 | 精品伊人久久久久7777人| 成人午夜在线视频| 91麻豆精品国产自产在线观看一区| 久久久蜜桃精品| 亚洲制服欧美中文字幕中文字幕| 国模娜娜一区二区三区| 欧美视频一二三区| 国产精品免费久久| 久久99精品视频| 欧美浪妇xxxx高跟鞋交| 国产精品欧美经典| 精品亚洲成av人在线观看| 在线观看国产一区二区| 亚洲国产精品v| 久久国产精品色| 欧美日韩亚洲综合一区| 综合久久国产九一剧情麻豆| 国模一区二区三区白浆| 欧美日韩国产色站一区二区三区| 中文字幕一区二区三区在线观看| 久久精品国产一区二区| 在线亚洲欧美专区二区| 国产精品女同一区二区三区| 久久99国产精品久久| 精品婷婷伊人一区三区三| 亚洲视频一二三区| 成人国产视频在线观看| 国产日韩欧美精品综合| 理论片日本一区| 日韩欧美亚洲另类制服综合在线| 亚洲国产成人高清精品| 欧美自拍偷拍午夜视频| 1024亚洲合集| 成人午夜激情影院| 久久人人爽爽爽人久久久| 另类小说一区二区三区| 欧美一二三区在线观看| 日韩av成人高清| 3d成人动漫网站| 午夜精品在线看| 欧美午夜一区二区| 亚洲国产aⅴ成人精品无吗| 色88888久久久久久影院野外| 中文字幕一区二区三区色视频| www.66久久| 一区二区不卡在线播放 |