/[debian]/nanobloggermail/trunk/nb_mail
ViewVC logotype

Contents of /nanobloggermail/trunk/nb_mail

Parent Directory Parent Directory | Revision Log Revision Log


Revision 159 - (show annotations)
Sat Feb 25 18:10:05 2006 UTC (15 years, 1 month ago) by gregoa
File size: 1035 byte(s)
Load nanobloggermail-0.2 into debian/nanobloggermail/trunk.

1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 # how are we called?
7 if (! $ARGV[0]) { print STDERR "Call as nb_mail \$blog_dir."; exit(1); }
8
9 my ($message, $msgstring);
10 my ($title, $cat, $body);
11 my ($blog_dir, $status);
12
13 # blog directory
14 $blog_dir = $ARGV[0];
15 chomp($blog_dir);
16 $blog_dir =~ s/~/$ENV{HOME}/;
17 $blog_dir .= '/' if ($blog_dir !~ /.*\/$/);
18
19 # read mail from STDIN
20 if (!open(IN, '-')) { print STDERR "Could not read from STDIN: $!\n"; exit(1); }
21 my @message = <IN>;
22 close IN;
23
24 # create one string
25 foreach my $line (@message) {
26 chomp($line);
27 next if ($line =~/^$/);
28 $msgstring .= $line;
29 }
30
31 # grep variables
32 ($title, $cat, $body) = ($msgstring =~ /^.*TITLE:\s*(.+?)\s*CAT:\s*(.+?)\s*BODY:\s*(.+?)\s*$/);
33
34 #print "title: $title\n";
35 #print "cat: $cat\n";
36 #print "body: $body\n";
37
38
39 # call nb
40 umask 0002;
41 $status = system("PATH=\"/usr/local/bin:/usr/bin:/bin\" nb -b $blog_dir -c $cat -t \"$title\" -B \"$body\" -a");
42 if ($status != 0) { print STDERR "Error while executing nb: $?\n"; exit(1); }
43 print "$status\n";
44 exit (0);

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26