Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
GWN automagically sent to your Mailbox
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Ginko
Guru
Guru


Joined: 01 May 2002
Posts: 371
Location: nearby my linux laptop

PostPosted: Fri Oct 03, 2003 9:14 am    Post subject: GWN automagically sent to your Mailbox Reply with quote

In case you want to get the GWN (Gentoo Weekly Newsletter) automagically sent to your mailbox as soon as it appears on the Web (well more or less), do so :

Add the following file in /etc/cron.daily/name-it-as-you-wish :
Code:
#!/usr/bin/perl -w
#
######################################################################
#
#                  __
#     ____ ___  __/ /_____  ____ __      ______
#    / __ `/ / / / __/ __ \/ __ `/ | /| / / __ \
#   / /_/ / /_/ / /_/ /_/ / /_/ /| |/ |/ / / / /
#   \__,_/\__,_/\__/\____/\__, / |__/|__/_/ /_/
#                        /____/
#
#  Created on:   Wed Sep 24 19:14:22 2003
#  Author:       Gianluca rotoni, Software Engineer
#
#  Copyright (C) 2003 Gianluca Rotoni <gianluca@rotoni.com>
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place - Suite 330,
#  Boston, MA  02111-1307, USA.
#
######################################################################
#
# A script to automagically send the Gentoo Weekly Newsletter via Mail

use strict;
use LWP::Simple;
use MIME::Lite;

package main;


# Configuration Parameters
#
# Define the desired language
#
# Valid languages are :
#
# be (Dutch)
# en (English)
# de (German)
# fr (French)
# ja (Japanese)
# it (Italian)
# pl (Polish)
# br (Portuguese Brazil)
# pt (Portuguese Portugal)
# ru (Russian)
# es (Spanish)
# tr (Turkish)
#
my $language = "en";

#
# Mail configuration
#
my $gwn_recipient = "you\@your-domain";
my $gwn_sender = "gwn\@gentoo.org";
my $tmp_dir = "/var/tmp";

#
# Get todays date, if it's not Monday get latest Monday's date
#
my $time = time();
my $monday = 1;
my $wday = (localtime)[6];

if ($wday != $monday) {
  for ($time=time(); (localtime($time))[6] != $monday; $time -= 86400) {}
}

#
# Format last Monday's date as YYYYMMDD
#
my ($year,$month,$day) = (localtime($time))[5,4,3];
my $datum = sprintf("%d%02d%02d", $year + 1900, $month+1, $day);

#
# Do not continue if this week's GWN has already been read
#
exit 0 if (-f "$tmp_dir/.$datum.gwn");

#
# Calculate last Monday's GWN url
#
my $gwn_url = "http://www.gentoo.org/news/$language/gwn/$datum-newsletter.xml";

#
# Get the GWN via Web
#
my $gwn_content = get($gwn_url);
exit 1 unless defined $gwn_content;

my $gwn_msg = MIME::Lite->new(
                              To      => $gwn_recipient,
                              From    => $gwn_sender,
                              Subject => "Gentoo Weekly Newsletter ($datum,$language)",
                              Type    => 'text/html',
                              Data    => $gwn_content,
                             );

$gwn_msg->send;

#

# Set this week's GWN as read
#
open (GWN, ">$tmp_dir/.$datum.gwn") or exit 1;
print GWN $datum;
close GWN;

exit;

1;

Do not forget to chmod u+x the file. You will need LWP::Simple e MIME::Lite.

Happy GWN readin' :-)
--Gianluca
Back to top
View user's profile Send private message
lutzh
n00b
n00b


Joined: 27 Sep 2003
Posts: 45
Location: Hamburg, Germany

PostPosted: Fri Oct 03, 2003 10:20 am    Post subject: Reply with quote

Eh, wouldn't it be kind of easier to just send a blank email to gentoo-gwn-subscribe@gentoo.org, as to subscribe to it?
Back to top
View user's profile Send private message
Ginko
Guru
Guru


Joined: 01 May 2002
Posts: 371
Location: nearby my linux laptop

PostPosted: Fri Oct 03, 2003 11:44 am    Post subject: Reply with quote

lutzh wrote:
Eh, wouldn't it be kind of easier to just send a blank email to gentoo-gwn-subscribe@gentoo.org, as to subscribe to it?

Not if you want it in other languages than English afaik.

--Gianluca
Back to top
View user's profile Send private message
nirp1981
n00b
n00b


Joined: 08 Mar 2008
Posts: 1

PostPosted: Sat Mar 08, 2008 1:52 pm    Post subject: Reply with quote

hey!
is it possible in hebrew too or just
the lenguages written over here?
thanks...
nirp from DiscussFitness
Back to top
View user's profile Send private message
neysx
Retired Dev
Retired Dev


Joined: 27 Jan 2003
Posts: 795

PostPosted: Sat Mar 08, 2008 3:20 pm    Post subject: Reply with quote

Ginko wrote:
lutzh wrote:
Eh, wouldn't it be kind of easier to just send a blank email to gentoo-gwn-subscribe@gentoo.org, as to subscribe to it?

Not if you want it in other languages than English afaik.

--Gianluca
Lists exist for other languages as well.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum