source: devel/pb/bin/mkannounce.pl @ 5

Last change on this file since 5 was 5, checked in by bruno, 12 years ago

Lots of modifs to find the right way. Probably still not good

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/bin/perl -w
2#
3# Creates announces for new mondorescue version/tag
4#
5# $Id$
6#
7# Syntax : mkannounce announce-file
8#
9
10use strict;
11use Date::Manip;
12use File::Basename;
13use DBI;
14use English;
15
16
17# For date handling
18$ENV{LANG}="C";
19
20my $PBROOT;
21my $tmp = dirname($PROGRAM_NAME);
22print "$tmp\n";
23if ($tmp =~ /^\//) {
24    $PBROOT = $tmp;
25    }
26else {
27    $PBROOT = "$ENV{PWD}/$tmp";
28    }
29
30my $db="$PBROOT/../website/announces3.sql";
31
32my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","",
33            { RaiseError => 1, AutoCommit => 1 }) 
34            || die "Unable to connect to $db";
35
36my $date = &UnixDate("today","%Y-%m-%d");
37
38# To read whole file
39local $/;
40open(ANNOUNCE,$ARGV[0]) || die "Unable to open $ARGV[0] (read)";
41my $announce = <ANNOUNCE>;
42#$announce =~ s/\"/\"\"/g;
43#$announce =~ s/!//g;
44close(ANNOUNCE);
45
46print "INSERT INTO announces VALUES (NULL, $date, $announce)\n";
47my $sth = $dbh->prepare(qq{INSERT INTO announces VALUES (NULL,?,?)}) 
48        || die "Unable to insert into $db";
49$sth->execute($date, $announce);
50#$dbh->do(qq(INSERT INTO announces VALUES (NULL, '$date', '$announce')))
51#|| die "Unable to insert into $db";
52
53$dbh->disconnect;
Note: See TracBrowser for help on using the repository browser.