Handover Phist wrote:
> OK, here's where I'm at. I've gotten my hands on a good working stats
> script, configured and tested it successfully. Now I need to create a
> script that will post the stats to my server (leafnode@localhost). This
> is what I have so far:
> ----------------------
> #!/bin/bash
> ##############################################
> #
> # stats autoposter
> #
> ##############################################
> echo "POST" > ~/bin/stats
> echo "From: Test Newsstat Guy" >> ~/bin/stats
> echo "Newsgroups: alt.test" >> ~/bin/stats
> echo "Subject: Stats for $NG" >> ~/bin/stats
> echo >> ~/bin/stats
> ~/bin/newsstat.pl $NG >> ~/bin/stats
> echo "." >> ~/bin/stats
> echo "QUIT" >> ~/bin/stats
> telnet localhost 119 << ~/bin/stats
> exit 0
> ------------------------
> NG = whatever group I wish to stat. It works in theory and in practice
> when I copy and paste the file into a telnet session. I think this
> method of dumping the file to the session is going too fast for the news
> server to parse the commands. Thoughts?
Here's the Perl script I use to post the stats here in cola. I use the
same (appropriately edited of course) script to post the weekly stats in
alt.machines.cnc too. You'd probably need to install several Perl
modules as listed below as they are not part of a default Perl
installation. Not a Perl install from FreeBSD ports, anyway. "thor" is
my local news server (INN). See the man page for Net::NNTP if you need to
authenticate with a news server.
HTH
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/usr/bin/perl -w
use lib '/usr/home/blkdrgn/perl/lib/perl5/site_perl/5.8.7';
use Net::NNTP;
use Date::Format;
use Date::Manip;
open(MSG1, "< /usr/home/blkdrgn/usenet/cola-stats/colanotes")
or die "Could not open colanotes\n";
open(MSG2, "< /usr/home/blkdrgn/usenet/cola-stats/newsstat7.stats")
or die "Could not open newsstat7.stats\n";
open(MSG3, "< /usr/home/blkdrgn/usenet/cola-stats/turq30.stats")
or die "Could not open turq30.stats\n";
while(<MSG1>) {
chomp;
@BODY1 = <MSG1>;
}
while(<MSG2>) {
chomp;
@BODY2 = <MSG2>;
}
while(<MSG3>) {
chomp;
@BODY3 = <MSG3>;
}
my @expires = gmtime(&UnixDate(&DateCalc("today","+ 7 days"), "%o"));
my $expiresfmt = strftime "%a, %d %b %Y %H:%M:%S %z", @expires;
my @gmt = gmtime(time);
my $gmtfmt = strftime "%d %b %Y", @gmt;
@HEADER = ("From: Black Dragon <stats.cola\@gmail.com>\n",
"Newsgroups: comp.os.linux.advocacy\n",
"Subject: Statistics for comp.os.linux.advocacy, $gmtfmt\n",
"Organization: Black Dragon Heavy Industries\n",
"Expires: $expiresfmt\n");
print @HEADER;
print @BODY1;
print @BODY2;
print @BODY3;
$SERVER = Net::NNTP->new("thor");
$SERVER->post(@HEADER, "\n", @BODY1, "\n", @BODY2, "\n", @BODY3)
or die "Could not post\n";
exit;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
Black Dragon
"If God had wanted us to use the metric system, Jesus would have had 10
apostles."
|
|