#!/usr/local/bin/perl
$tmp_posting = "/tmp/post2news.$$";
$tmp_inews = "/tmp/inews.$$";
$dest = $ARGV[0];
$gatewayaddress = "gateway\@newsstand.cit.cornell.edu";
$inews = "/inn/bin/inews";
open (INLIST, "cat >>".$tmp_posting." -|") || die "Foo. $!\n";
sleep(2);
close(INLIST);
open (DATAFILE, "<".$tmp_posting) || die "Bar. $!\n";
open (OUTFILE, ">".$tmp_inews) || die "Baz. $!\n";
while($line = ) {
chop($line);
# print STDOUT "$line\n";
last if ($line =~ /^\s+$/); # Blank line means end of headers.
($head,$text) = split(": ",$line,2);
$Headers{$head} = $text;
}
if (!$Headers{"Sender"}) {
$Headers{"Sender"} = $gatewayaddress;
}
# Build up the news posting.
print OUTFILE "From: $Headers{'From'}\n";
print OUTFILE "Newsgroups: $dest\n";
print OUTFILE "Subject: $Headers{'Subject'}\n";
print OUTFILE "Path: mail-to-news\n";
while (($head,$text) = each %Headers) {
if (($head ne "From")
&& ($head ne "Subject")
&& ($head ne "To")
&& ($head ne "Received")) {
print OUTFILE "$head: $text\n";
}
}
print OUTFILE "\n";
while ($line = ) {
print OUTFILE $line;
}
close (OUTFILE);
system( "$inews -h < $tmp_inews");
unlink($tmp_posting);
unlink($tmp_inews);
|