Home Download News FAQ / Knowledge Base Screenshots Documentation Support
philosophical imaginary

Differences

This shows you the differences between two versions of the page.

installation:calendar.paging.script [2008/03/09 17:04] (current)
dothebart larry Ives Calendar Paging script
Line 1: Line 1:
 +=====Calendar Paging====
 +Larry Ives provides this usefull script to page Users when they've got dates in their calendar:
  
 +My users wanted to have their calendar events "pop-up" when the event time came about so I turned to my trust friend Perl and wrote a script. If anyone is interested it is free for the taking. (Use at your own risk) I put the script in cron which goes off every 5 minutes. It cycles though all of the users and looks for calendar events which are +/- 200 seconds from current Linux system time and sends an instant message to that user telling them about the event. You will need to have pop-up blocker turned off naturally. You will also need the **//Date::Calc//** and **//Net::Telnet//** modules for perl.
 +<code perl>
 +#!/usr/bin/perl -w
 +use Date::Calc qw(Mktime Today_and_Now);
 +use strict;
 +use Net::Telnet ();
 +
 +my ($s, %nusrs, @mnums, $caltime, $m, $ldt, $hdt, $subj);
 +
 +my @usrlist = ('user1', 'user2', 'user3');
 +my $user = 'admin';
 +my $pass = 'xxxxx';
 +my $fldr = 'calendar';
 +my $dt = Mktime(Today_and_Now());
 +# the cron is set to check for calendar events every 5 minutes
 +# so the script checks for events +/- 200 seconds
 +$ldt = $dt - 200;
 +$hdt = $dt + 200;
 +
 +#logs in as admin (administrative account)
 +my $t = new Net::Telnet;
 +$t->open(Host => 'localhost', Port => 504);
 +$s = $t->getline;
 +$t->print("USER $user");
 +$s = $t->getline;
 +$t->print("PASS $pass");
 +$s = $t->getline;
 +
 +# gets the password for each user
 +foreach (@usrlist)
 +{
 + $t->print("GREG $_");
 + $s = $t->getline;
 + $s = $t->getline;
 + $s = $t->getline;
 + chomp($s);
 + $nusrs{$_} = $s;
 + for (my $int=1; $int<11; $int++)
 + {
 +  $s = $t->getline;
 + }
 +}
 +$t->print("LOUT");
 +$s = $t->getline;
 +
 +# for each user the scripts checks their calendar events to
 +# see if there is one that is within 200 seconds +/-
 +foreach (@usrlist)
 +{
 + $t->print("USER $_");
 + $s = $t->getline;
 + $t->print("PASS $nusrs{$_}");
 + $s = $t->getline;
 + $t->print("GOTO $fldr");
 + $s = $t->getline;
 + $s = $t->print('MSGS');
 + $s = $t->getline;
 + $s = $t->getline;
 +
 + do
 + {
 +  chomp($s);
 +  push(@mnums, $s);
 +  $s = $t->getline;
 + } until ($s == 000);
 +
 + foreach $m (@mnums) # loops through calendar messages (header and body)
 + {
 +  $s = $t->print("MSG0 $m|1");
 +  $s = $t->getline;
 +
 +  while (!($s =~ /^000/)) #  
 +  {
 +   if ($s =~ /^time=/)
 +   {
 +    my @ctime = split(/=/, $s);
 +    $caltime = $ctime[1];
 +   }
 +   if ($s =~ /^subj=/)
 +   {
 +    my @subject = split(/=/, $s);
 +    if (($caltime > $ldt) and ($caltime < $hdt))
 +    {
 +     $subj = $subject[1];
 +     print "$caltime $subj"; #
 +    }
 +   }
 +   $s = $t->getline;
 +  }
 + }
 +
 +# sends the chat message to the user with a current calendar event
 +$s = $t->print("SEXP $_|$subj");
 +$s = $t->getline;
 +$t->print("LOUT");
 +$s = $t->getline;
 +@mnums = ();
 +}
 +
 +exit;
 +</code>
Copyright © 1987-2020 Uncensored Communications Group. All rights reserved.     Login (site admin)