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

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

?? psa-chapter08.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 Eight
=============

#*
#* sending mail using sendmail (from the Perl FAQ)
#*

# assumes we have sendmail installed
open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or 
  die "Can't fork for sendmail: $!\n";
print SENDMAIL <<"EOF";
From: User Originating Mail <me\@host>
To: Final Destination <you\@otherhost>
Subject: A relevant subject line

Body of the message goes here after the blank line
in as many lines as you like.
EOF
close(SENDMAIL) or warn "sendmail didn't close nicely"; 
-------
#*
#* sending mail using AppleScript from MacPerl
#*

$to="someone\@example.com";
$from="me\@example.com";
$subject="Hi there";
$body="message body\n";

MacPerl::DoAppleScript(<<EOC);
tell application "Eudora"

    make message at end of mailbox "out"
       
    -- 0 is the current message
    set field \"from\" of message 0 to \"$from\"
    set field \"to\" of message 0 to \"$to\"
    set field \"subject\" of message 0 to \"$subject\"
    set body of message 0 to \"$body\"
    queue message 0
    connect with sending without checking
    quit
end tell
EOC
-------
#*
#* send mail using Apple Events from MacPerl
#*

use Mac::Glue ':glue';

$e=new Mac::Glue 'Eudora';
$to="someone\@example.com";
$from="me\@example.com";
$subject="Hi there";
$body="message body";

$e->make(
	new => 'message',
	at => location(end => $e->obj(mailbox => 'Out'))
);

$e->set($e->obj(field => from    => message => 0), to => $from);
$e->set($e->obj(field => to      => message => 0), to => $to);
$e->set($e->obj(field => subject => message => 0), to => $subject);
$e->set($e->prop(body => message => 0), to => $body);

$e->queue($e->obj(message => 0));
$e->connect(sending => 1, checking => 0);
$e->quit;
-------
#*
#* send mail using MAPI (via OLE) with Outlook on NT/2000
#*

$to="me\@example.com";
$subject="Hi there";
$body="message body\n";

use Win32::OLE;

# init OLE, COINIT_OLEINITIALIZE required when using MAPI.Session objects
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# create a session object that will call Logoff when it is destroyed
my $session = Win32::OLE->new('MAPI.Session','Logoff');
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# log into that session using the default OL98 Internet Profile
$session->Logon('Microsoft Outlook Internet Settings');
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# create a message object
my $message = $session->Outbox->Messages->Add;
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# create a recipient object for that message object
my $recipient = $message->Recipients->Add;
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# populate the recipient object
$recipient->{Name} = $to;
$recipient->{Type} = 1; # 1 = "To:", 2 = "Cc:", 3 = "Bcc:"

# all addresses have to be resolved against a directory 
# (in this case probably your Address book). Full addresses 
# usually resolve to themselves, so this line in most cases will 
# not modify the recipient object.
$recipient->Resolve();
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# populate the Subject: line and message body
$message->{Subject} = $subject;
$message->{Text} = $body;

# queue the message to be sent
# 1st argument = save copy of message
# 2nd argument = allows user to change message w/dialog box before sent
# 3rd argument = parent window of dialog if 2nd argument is True
$message->Send(0, 0, 0);
die Win32::OLE->LastError(),"\n" if Win32::OLE->LastError();

# explicitly destroy the $session object, calling $session->Logoff 
# in the process
undef $session; 
-------
#*
#* sending mail using Mail::Mailer
#*

use Mail::Mailer;

$from="me\@example.com";
$to="you\@example.com";
$subject="Hi there";
$body="message body\n";

$type="smtp";
$server="mail.example.com";

my $mailer = Mail::Mailer->new($type, Server => $server) or
  die "Unable to create new mailer object:$!\n";

$mailer->open({From => $from, 
               To => $to, 
               Subject => $subject}) or 
  die "Unable to populate mailer object:$!\n";

print $mailer $body;
$mailer->close;
-------
#*
#* subroutine for performing exponential backoff (uses a closure)
#*

$max  = 24*60*60; # maximum amount of delay in seconds (1 day)
$unit = 60;       # increase delay by measures of this unit (1 min)

# provide a closure with the time we last sent a message and 
# the last power of 2 we used to compute the delay interval. 
# The subroutine we create will return a reference to an 
# anonymous array with this information
sub time_closure {
    my($stored_sent,$stored_power)=(0,-1);
    return sub {
       (($stored_sent,$stored_power) = @_) if @_;
       [$stored_sent,$stored_power];
    }
};

$last_data=&time_closure; # create our closure

# return true first time called and then once after an 
# exponential delay
sub expbackoff {
    my($last_sent,$last_power) = @{&$last_data};

    # reply true if this is the first time we've been asked, or if the
    # current delay has elapsed since we last asked. If we return true, 
    # we stash away the time of our last affirmative reply and increase 
    # the power of 2 used to compute the delay.
    if (!$last_sent or
       ($last_sent + 
         (($unit * 2**$last_power >= $max) ? 
             $max : $unit * 2**$last_power) <= time())){
         	       &$last_data(time(),++$last_power);
              return 1;
    }
    else {
	   return 0;
    }
}
-------
#*
#* subroutine for performing exponential ramp up (uses a closure)
#*

$max  = 60*60*24; # maximum amount of delay in seconds (1 day)
$min  = 60*5;     # minimum amount of delay in seconds (5 minutes)
$unit = 60;       # decrease delay by measures of this unit (1 min)

$start_power = int log($max/$unit)/log(2); # find the closest power of 2 

sub time_closure {
    my($last_sent,$last_power)=(0,$start_power+1);
    return sub {
	(($last_sent,$last_power) = @_) if @_;
	# keep exponent positive
	$last_power = ($last_power > 0) ? $last_power : 0; 
	[$last_sent,$last_power];
    }
};

$last_data=&time_closure; # create our closure

# return true first time called and then once after an 
# exponential ramp up
sub exprampup {
    my($last_sent,$last_power) = @{&$last_data};

    # reply true if this is the first time we've been asked, or if the
    # current delay has elapsed since we last asked. If we send, we
    # stash away the time of our last affirmative reply and increased
    # power of 2 used to compute the delay.
    if (!$last_sent or
	($last_sent + 
         (($unit * 2**$last_power <= $min) ? 
	  $min : $unit * 2**$last_power) <= time())){
	    &$last_data(time(),--$last_power);
            return 1;
    }
    else {
	return 0;
    }
}
-------
#*
#* a program that collates the responses of several machines and sends out
#* a summary piece of email
#*

use Mail::Mailer;
use Text::Wrap;

# the list of machine reporting in
$repolist = "/project/machinelist"; 
# the directory where they write files
$repodir  = "/project/reportddir";  
# filesystem separator for portability, 
# could use File::Spec module instead 
$separator= "/";                    
# send mail "from" this address
$reportfromaddr  = "project\@example.com"; 
# send mail to this address
$reporttoaddr    = "project\@example.com"; 
# read the list of machine reporting in into a hash. 
# Later we de-populate this hash as each machine reports in, 
# leaving behind only the machine which are missing in action
open(LIST,$repolist) or die "Unable to open list $repolist:$!\n";
while(<LIST>){
    chomp;
    $missing{$_}=1;
    $machines++;
}

# read all of the files in the central report directory
# note:this directory should be cleaned out automatically 
# by another script
opendir(REPO,$repodir) or die "Unable to open dir $repodir:$!\n";

while(defined($statfile=readdir(REPO))){
    next unless -f $repodir.$separator.$statfile;
    
    # open each status file and read in the one-line status report
    open(STAT,$repodir.$separator.$statfile) 
      or die "Unable to open $statfile:$!\n";

    chomp($report = <STAT>);

    ($hostname,$result,$details)=split(' ',$report,3);

    warn "$statfile said it was generated by $hostname!\n"
      if($hostname ne $statfile);

    # hostname is no longer considered missing
    delete $missing{$hostname}; 
    # populate these hashes based on success or failure reported
    if ($result eq "success"){
        $success{$hostname}=$details;
        $succeeded++;
    }
    else {
        $fail{$hostname}=$details;
        $failed++;
    }	
    close(STAT);
}		
closedir(REPO);

# construct a useful subject for our mail message
if ($successes == $machines){
    $subject = "[report] Success: $machines";
}
elsif ($failed == $machines or scalar keys %missing >= $machines) {
    $subject = "[report] Fail: $machines";
}
else {
    $subject = "[report] Partial: $succeeded ACK, $failed NACK".
      ((%missing) ? ", ".scalar keys %missing." MIA" : "");
}

# create the mailer object and populate the headers
$type="sendmail"; 
my $mailer = Mail::Mailer->new($type) or
  die "Unable to create new mailer object:$!\n";

$mailer->open({From=>$reportfromaddr, To=>$reporttoaddr, Subject=>$subject}) or 
  die "Unable to populate mailer object:$!\n";

# create the body of the message
print $mailer "Run report from $0 on " . scalar localtime(time) . "\n";

if (keys %success){
    print $mailer "\n==Succeeded==\n";
    foreach $hostname (sort keys %success){
	print $mailer "$hostname: $success{$hostname}\n";
    }
}

if (keys %fail){
    print $mailer "\n==Failed==\n";
    foreach $hostname (sort keys %fail){
	print $mailer "$hostname: $fail{$hostname}\n";
    }
}

if (keys %missing){
    print $mailer "\n==Missing==\n";
    print $mailer wrap("","",join(" ",sort keys %missing)),"\n";
}

# send the message
$mailer->close;
-------
#*
#* a simple network logging daemon that collates responses
#*

use IO::Socket;
use Text::Wrap; # used to make the output prettier

# the list of machine reporting in
$repolist = "/project/machinelist"; 
# the port number clients should connect to 
$serverport = "9967";               

&loadmachines; # load the machine list

# set up our side of the socket
$reserver = IO::Socket::INET->new(LocalPort => $serverport,
                                  Proto     => "tcp",
                                  Type      => SOCK_STREAM,
                                  Listen    => 5,
                                  Reuse     => 1)
  or die "Unable to build our socket half: $!\n";

# start listening on it for connects
while(($connectsock,$connectaddr) = $reserver->accept()){

    # the name of the client which has connected to us
    $connectname = gethostbyaddr((sockaddr_in($connectaddr))[1],AF_INET);

    chomp($report=$connectsock->getline);

    ($hostname,$result,$details)=split(' ',$report,3);

    # if we've been told to dump our info, print out a ready-to-go mail
    # message and reinitialize all of our hashes/counters
    if ($hostname eq "DUMPNOW"){
	&printmail($connectsock);
	close($connectsock);
	undef %success;
	undef %fail;
	$succeeded = $failed = 0;
	&loadmachines;
	next;
    }

    warn "$connectname said it was generated by $hostname!\n"
      if($hostname ne $connectname);
    delete $missing{$hostname};
    if ($result eq "success"){
	$success{$hostname}=$details;
	$succeeded++;
    }
    else {
	$fail{$hostname}=$details;
	$failed++;
    }	
    close($connectsock);
}
close($reserver);

# loads the list of machines from the given file
sub loadmachines {
    undef %missing;
    undef $machines; 
    open(LIST,$repolist) or die "Unable to open list $repolist:$!\n";
    while(<LIST>){
	chomp;
	$missing{$_}=1;
	$machines++;
    }
}

# prints a ready to go mail message. The first line is the subject, 
# subsequent lines are all the body of the message
sub printmail{
    ($socket) = $_[0];

    if ($successes == $machines){
	$subject = "[report] Success: $machines";
    }
    elsif ($failed == $machines or scalar keys %missing >= $machines) {
	$subject = "[report] Fail: $machines";
    }
    else {
	$subject = "[report] Partial: $succeeded ACK, $failed NACK".
	  ((%missing) ? ", ".scalar keys %missing." MIA" : "");
    }

    print $socket "$subject\n";
    
    print $socket "Run report from $0 on ".scalar localtime(time)."\n";

    if (keys %success){
	print $socket "\n==Succeeded==\n";
	foreach $hostname (sort keys %success){
	    print $socket "$hostname: $success{$hostname}\n";
	}
    }

    if (keys %fail){
	print $socket "\n==Failed==\n";
	foreach $hostname (sort keys %fail){
	    print $socket "$hostname: $fail{$hostname}\n";
	}
    }

    if (keys %missing){
	print $socket "\n==Missing==\n";
	print $socket wrap("","",join(" ",sort keys %missing)),"\n";
    }
}
-------
#*
#* a sample client for the above daemon
#*

use IO::Socket;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产·精品毛片| 蜜臀久久99精品久久久久宅男 | 一区二区三区欧美久久| 色综合网色综合| 亚洲一区二三区| 日韩一区国产二区欧美三区| 国产中文一区二区三区| 国产人伦精品一区二区| av亚洲精华国产精华精华| 一区二区三区国产| 日韩久久久久久| 国产91在线看| 美国一区二区三区在线播放| 日韩免费电影一区| 成人在线视频一区二区| 亚洲男人的天堂网| 日韩欧美成人午夜| av电影天堂一区二区在线观看| 亚洲精品欧美二区三区中文字幕| 欧美美女直播网站| 国产麻豆9l精品三级站| 亚洲男人电影天堂| 91精品国产福利| 福利91精品一区二区三区| 亚洲一本大道在线| 精品国产sm最大网站免费看 | 日本道色综合久久| 老汉av免费一区二区三区| 国产精品午夜久久| 欧美日韩国产高清一区二区三区| 精品在线播放免费| 亚洲猫色日本管| 26uuu国产一区二区三区| 色综合天天在线| 九色综合狠狠综合久久| 亚洲乱码国产乱码精品精98午夜| 欧美一区二区三区免费大片| 不卡的电影网站| 美女免费视频一区二区| 亚洲欧美另类综合偷拍| 久久天堂av综合合色蜜桃网| 欧美tk—视频vk| 色综合久久中文字幕| 老色鬼精品视频在线观看播放| 亚洲欧洲无码一区二区三区| 精品久久99ma| 在线电影国产精品| 日本久久电影网| 国产精品1区2区3区| 日韩精品一二三区| 亚洲欧美日韩中文播放| 中文字幕欧美区| 日韩免费高清电影| 91精品啪在线观看国产60岁| 日本韩国精品一区二区在线观看| 成人综合在线观看| 国产一区二三区| 久久国产精品72免费观看| 婷婷夜色潮精品综合在线| 亚洲欧美欧美一区二区三区| 国产精品久久免费看| 国产视频一区在线观看| 久久亚洲一级片| 日韩欧美不卡一区| 欧美一区二区精品| 日韩欧美区一区二| 日韩欧美国产午夜精品| 91精品国产欧美一区二区成人| 欧美日韩一卡二卡三卡| 91黄色免费看| 在线观看免费成人| 欧美午夜影院一区| 欧美在线三级电影| 91精彩视频在线| 91一区二区在线| 色综合天天性综合| 在线观看一区二区视频| 色综合夜色一区| 欧美自拍丝袜亚洲| 欧美日本国产视频| 日韩一级完整毛片| 精品国产露脸精彩对白| 久久先锋资源网| 欧美国产乱子伦 | fc2成人免费人成在线观看播放| 国产精品77777竹菊影视小说| 国产一区二区在线观看视频| 国产福利一区二区| 99精品在线观看视频| 色94色欧美sute亚洲13| 欧美日韩精品三区| 欧美电影精品一区二区| 久久精品一区二区三区不卡牛牛| 国产精品人妖ts系列视频| 亚洲色图欧美激情| 午夜在线成人av| 久久se精品一区精品二区| 国产999精品久久久久久绿帽| 99久久精品一区| 欧美欧美欧美欧美首页| 精品国产网站在线观看| 欧美国产精品劲爆| 亚洲综合色噜噜狠狠| 日韩av一区二区三区| 国产盗摄视频一区二区三区| 97精品国产露脸对白| 欧美日韩高清一区二区| 久久综合色综合88| 亚洲乱码国产乱码精品精98午夜 | 欧美激情在线观看视频免费| 亚洲欧美在线观看| 日本vs亚洲vs韩国一区三区二区| 国产精品正在播放| 欧美体内she精高潮| 久久亚洲影视婷婷| 亚洲国产一区二区a毛片| 久久成人免费网| 99久久99久久精品免费观看| 日韩小视频在线观看专区| 中文字幕一区二区三区在线观看| 亚洲成av人片www| 成人综合在线网站| 精品日韩欧美一区二区| 亚洲视频图片小说| 久久精品国产久精国产爱| 91麻豆免费观看| 2020日本不卡一区二区视频| 亚洲与欧洲av电影| 岛国一区二区在线观看| 555www色欧美视频| 亚洲欧美韩国综合色| 国产精品一区二区在线观看网站| 欧美日韩精品一区二区在线播放| 中文字幕成人在线观看| 美国毛片一区二区| 欧美亚洲图片小说| 国产精品免费视频网站| 青青草伊人久久| 欧美三级电影在线观看| 国产精品天天看| 久久电影国产免费久久电影 | 91精品一区二区三区在线观看| 国产精品白丝在线| 国产乱码精品一区二区三| 欧美日韩国产综合一区二区三区| 17c精品麻豆一区二区免费| 国产精品一区一区三区| 欧美sm极限捆绑bd| 午夜精品久久久久久| 日本电影亚洲天堂一区| 18欧美亚洲精品| 成人高清视频在线| 欧美国产日本视频| 国产成人精品三级麻豆| 久久综合久久久久88| 久久精品国产亚洲a| 欧美一二三四在线| 日精品一区二区| 制服丝袜国产精品| 图片区小说区国产精品视频| 欧美午夜不卡在线观看免费| 国产黄色精品视频| 精品国产伦理网| 久久精品99久久久| 欧美精品一区二区三区视频| 日本一道高清亚洲日美韩| 在线不卡一区二区| 日本美女一区二区| 日韩一区二区三区电影| 另类小说综合欧美亚洲| 日韩一区二区免费电影| 激情综合色综合久久综合| 久久中文字幕电影| 国产suv精品一区二区三区| 中文字幕不卡在线| 91视频.com| 亚洲成a天堂v人片| 欧美一二三在线| 国产精品一二一区| 国产精品美女久久久久久久久久久| www.成人在线| 亚洲国产精品自拍| 日韩免费一区二区三区在线播放| 精品午夜久久福利影院| 国产午夜亚洲精品理论片色戒| 成人app软件下载大全免费| 一区二区三区在线视频观看58| 欧美日韩三级一区| 国内外成人在线视频| 国产精品国产三级国产aⅴ原创 | 欧美一区二区三区四区高清| 久久国产精品露脸对白| 中文av字幕一区| 欧美最猛性xxxxx直播| 婷婷激情综合网| 国产欧美日韩三区| 91成人免费在线| 激情综合色综合久久综合| 亚洲人成亚洲人成在线观看图片 | 免费在线观看成人|