#!/bin/perl
$option = $ARGV[0];
$my_html_dir = "/cise/homes/ppadala/public_html";
$tmp_file = "/tmp/tmp.out";
$start = 0;
$line = "";
if($option eq "announce") {
$line = "ANNOUNCEMENTS:";
}
elsif($option eq "notice") {
$line = "NOTICE:";
}
else {
exit(1);
}
while()
{ chomp;
if(/From.*/) {
$start = 0;
}
if($start == 1) {
chomp;
$line = $line . $_;
}
if($_ eq "") {
$start = 1;
}
}
$my_homepage_file = $my_html_dir . "/procmail.html";
open(MY_FILE, "<$my_homepage_file") || die("Cannot open input file");
open(TMP, ">$tmp_file") || die("Cannot open file");
$replace = 0;
while()
{ if($replace == 1) {
print TMP "var strStreamer = '${line}';\n";
$replace = 0;
next;
}
if(/\/\/Replace str.*/) {
$replace = 1;
print TMP $_;
}
else {
print TMP $_;
}
}
close(TMP);
close(MY_FILE);
system("mv $tmp_file $my_homepage_file");
system("chmod go+r $my_homepage_file");