Networker

Re: [Networker] Creating fancy schedules

2006-11-09 05:54:25
Subject: Re: [Networker] Creating fancy schedules
From: Yaron Zabary <yaron AT ARISTO.TAU.AC DOT IL>
To: NETWORKER AT LISTSERV.TEMPLE DOT EDU
Date: Thu, 9 Nov 2006 12:38:51 +0200
That is one of my perl scripts for dealing with schedules. It creates schedules for three months from now, so you need to run it every month or so. Notice that this script generates decreasing level weeklies. The if statements in the middle can be adjusted to whatever you like them to do.

#!/bin/perl

require "timelocal.pl";

open(OUT,">/tmp/nsradmin.in.eshkol");
print OUT ". name: Eshkol Home ; \n\n";

print OUT "\nupdate override: ";

# Find the week day of the first day of the month

($sec,$min,$hour,$mday,$monx,$year,$wday,$yday,$isdst) = localtime(time());
for ($m = 0; $m < 3 ; $m++ )
{
#print $year+int(($monx+$m)/12),"\n";
$timefirst = timelocal(1,1,1,1,($monx+$m)%12,$year+int(($monx+$m)/12));
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($timefirst);
$fr = 0;
for ($day = 1 ; $day <= 31 ; $day++)
{
($sec,$min,$hour,$mday,$newmon,$year,$wxday,$yday,$isdst) = localtime($timefirst+($day-1)*86400);
   last unless $mon == $newmon;
   print OUT ", " unless $day == 1;
   $level = 'incr';
   if ($wday%7 == 5)
   {
     $fr++;
     if ($fr == 1)
     {
       $level = 'full';
     }
     if ($fr > 1)
     {
       $level = 11 - 2 * $fr;
     }
   }
   if ($wday%7 == 6)
   {
       $level = 'skip';
   }
   $wday++;
   print OUT $level," ",$mon+1,"/",$day,"/",$year+1900;
}
print OUT (", ") unless $m == 2;
}
print OUT (";\nquit\n");
close(OUT);

system ("nsradmin -i /tmp/nsradmin.in.eshkol");

sleep 5;

To sign off this list, send email to listserv AT listserv.temple DOT edu and type 
"signoff networker" in the
body of the email. Please write to networker-request AT listserv.temple DOT edu 
if you have any problems
wit this list. You can access the archives at 
http://listserv.temple.edu/archives/networker.html or
via RSS at http://listserv.temple.edu/cgi-bin/wa?RSS&L=NETWORKER