3 # yapfaq Version 0.10 by Thomas Hochstein
4 # (Original author: Marc Brockschmidt)
6 # This script posts any project described in its config-file. Most people
7 # will use it in combination with cron(8).
9 # Copyright (C) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
10 # Copyright (c) 2010-2017 Thomas Hochstein <thh@inter.net>
12 # It can be redistributed and/or modified under the same terms under
13 # which Perl itself is published.
15 our $VERSION = "0.10";
17 # Please do not change this setting!
18 # You may override the default .rc file (.yapfaqrc) by using "-c .rc file"
19 my $RCFile = '.yapfaqrc';
20 # Valid configuration variables for use in a .rc file
21 my @ValidConfVars = ('NNTPServer','NNTPUser','NNTPPass','Sender','ConfigFile','Program');
23 ################################### Defaults ###################################
24 # Please do not change anything in here!
25 # Use a runtime configuration file (.yapfaqrc by default) to override defaults.
26 my %Config = (NNTPServer => "",
30 ConfigFile => "yapfaq.cfg",
33 ################################# Main program #################################
37 use Net::Domain qw(hostfqdn);
38 use Date::Calc qw(Add_Delta_YM Add_Delta_Days Delta_Days Today);
40 $Getopt::Std::STANDARD_HELP_VERSION = 1;
41 my ($TDY, $TDM, $TDD) = Today(); #TD: Today's date
43 # read commandline options
45 getopts('Vhvpdt:f:c:s:', \%Options);
46 # -V: print version / copyright information
48 print "$0 v $VERSION\nCopyright (c) 2003 Marc Brockschmidt <marc\@marcbrockschmidt.de>\nCopyright (c) 2010-2017 Thomas Hochstein <thh\@inter.net>\n";
49 print "This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.\n";
52 # -h: feed myself to perldoc
58 my ($Faq) = $Options{'f'} if ($Options{'f'});
60 # read runtime configuration (configuration variables)
61 $RCFile = $Options{'c'} if ($Options{'c'});
63 readrc (\$RCFile,\%Config);
65 warn "$0: W: .rc file $RCFile does not exist!\n";
68 $Options{'s'} = $Config{'Program'} if (defined($Config{'Program'}) && $Config{'Program'} && !defined($Options{'s'}));
70 # read configuration (configured FAQs)
72 readconfig (\$Config{'ConfigFile'}, \@Config, \$Faq);
75 # - parse configuration
77 # - if FAQ is due: call postfaq()
79 my ($LPD,$LPM,$LPY) = (01, 01, 0001); #LP: Last posting-date
80 my ($NPY,$NPM,$NPD); #NP: Next posting-date
83 my ($ActName,$File,$PFreq,$Expire) =($$_{'name'},$$_{'file'},$$_{'posting-frequency'},$$_{'expires'});
84 my ($From,$Subject,$NG,$Fup2)=($$_{'from'},$$_{'subject'},$$_{'ngs'},$$_{'fup2'});
85 my ($MIDF,$ReplyTo,$Charset,$ExtHea)=($$_{'mid-format'},$$_{'reply-to'},$$_{'charset'},$$_{'extraheader'});
86 my ($Supersede) =($$_{'supersede'});
88 # -f: loop if not FAQ to post
89 next if (defined($Faq) && $ActName ne $Faq);
92 if (open (FH, "<$File.cfg")) {
94 if (/##;; Lastpost:\s*(\d{1,2})\.(\d{1,2})\.(\d{2}(\d{2})?)/){
95 ($LPD, $LPM, $LPY) = ($1, $2, $3);
96 } elsif (/^##;;\s*LastMID:\s*(<\S+@\S+>)\s*$/) {
102 warn "$0: W: Couldn't open $File.cfg: $!\n";
105 $SupersedeMID = "" unless $Supersede;
107 ($NPY,$NPM,$NPD) = calcdelta ($LPY,$LPM,$LPD,$PFreq);
109 # if FAQ is due: get it out
110 if (Delta_Days($NPY,$NPM,$NPD,$TDY,$TDM,$TDD) >= 0 or ($Options{'p'})) {
112 print "$ActName: Would be posted now (but running in simulation mode [$0 -d]).\n" if $Options{'v'};
114 postfaq(\$ActName,\$File,\$From,\$Subject,\$NG,\$Fup2,\$MIDF,\$Charset,\$ExtHea,\$Config{'Sender'},\$TDY,\$TDM,\$TDD,\$ReplyTo,\$SupersedeMID,\$Expire);
116 } elsif($Options{'v'}) {
117 print "$ActName: Nothing to do.\n";
123 #################################### readrc ####################################
124 # Takes a filename and the reference to an array which contains the valid options
127 my ($File, $Config) = @_;
129 print "Reading $$File.\n" if($Options{'v'});
131 open FH, "<$$File" or die "$0: Can't open $$File: $!";
133 if (/^\s*(\S+)\s*=\s*'?(.*?)'?\s*(#.*$|$)/) {
134 if (grep(/$1/,@ValidConfVars)) {
135 $$Config{$1} = $2 if $2 ne '';
137 warn "$0: W: $1 is not a valid configuration variable (reading from $$File)\n";
143 ################################## readconfig ##################################
144 # Takes a filename, a reference to an array, which will hold hashes with
145 # the data from $File, and - optionally - the name of the (single) FAQ to post
148 my ($File, $Config, $Faq) = @_;
149 my ($LastEntry, $Error, $i) = ('','',0);
151 print "Reading configuration from $$File.\n" if($Options{'v'});
153 open FH, "<$$File" or die "$0: E: Can't open $$File: $!";
155 next if (defined($$Faq) && !/^\s*=====\s*$/ && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
156 if (/^(\s*(\S+)\s*=\s*'?(.*?)'?\s*(#.*$|$)|^(.*?)'?\s*(#.*$|$))/ && not /^\s*$/) {
157 $LastEntry = lc($2) if $2;
158 $$Config[$i]{$LastEntry} .= $3 if $3;
159 $$Config[$i]{$LastEntry} .= "\n$5" if $5 && $5;
161 if (/^\s*=====\s*$/) {
169 next if (defined($$Faq) && defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} ne $$Faq );
170 unless(defined($$Config[$i]{'name'}) && $$Config[$i]{'name'} =~ /^\S+$/) {
171 $Error .= "E: The name of your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
173 unless(defined($$Config[$i]{'file'}) && -f $$Config[$i]{'file'}) {
174 $Error .= "E: The file to post for your project \"$$Config[$i]{'name'}\" is not defined or does not exist.\n"
176 unless(defined($$Config[$i]{'from'}) && $$Config[$i]{'from'} =~ /\S+\@(\S+\.)?\S{2,}\.\S{2,}/) {
177 $Error .= "E: The From header for your project \"$$Config[$i]{'name'}\" seems to be incorrect.\n"
179 unless(defined($$Config[$i]{'ngs'}) && $$Config[$i]{'ngs'} =~ /^\S+$/) {
180 $Error .= "E: The Newsgroups header for your project \"$$Config[$i]{'name'}\" is not defined or contains whitespaces.\n"
182 unless(defined($$Config[$i]{'subject'})) {
183 $Error .= "E: The Subject header for your project \"$$Config[$i]{'name'}\" is not defined.\n"
185 unless(!$$Config[$i]{'fup2'} || $$Config[$i]{'fup2'} =~ /^\S+$/) {
186 $Error .= "E: The Followup-To header for your project \"$$Config[$i]{'name'}\" contains whitespaces.\n"
188 unless(defined($$Config[$i]{'posting-frequency'}) && $$Config[$i]{'posting-frequency'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
189 $Error .= "E: The Posting-frequency for your project \"$$Config[$i]{'name'}\" is invalid.\n"
191 unless(!$$Config[$i]{'expires'} || $$Config[$i]{'expires'} =~ /^\s*\d+\s*[dwmy]\s*$/) {
192 warn "$0: W: The Expires for your project \"$$Config[$i]{'name'}\" is invalid - set to 3 month.\n";
193 $$Config[$i]{'expires'} = '3m'; # set default (3 month) if expires is unset or invalid
195 unless(!$$Config[$i]{'mid-format'} || $$Config[$i]{'mid-format'} =~ /^<\S+\@(\S+\.)?\S{2,}\.\S{2,}>/) {
196 warn "$0: W: The Message-ID format for your project \"$$Config[$i]{'name'}\" seems to be invalid - set to default.\n";
197 $$Config[$i]{'mid-format'} = '<%n-%y-%m-%d@'.hostfqdn.'>'; # set default if mid-format is invalid
199 unless(defined($$Config[$i]{'charset'})) {
200 warn "$0: W: Your project \"$$Config[$i]{'name'}\" has no encoding defined - set to default (UTF-8).\n";
201 $$Config[$i]{'charset'} = 'UTF-8';
204 $Error .= "-" x 25 . 'program terminated' . "-" x 25 . "\n" if $Error;
205 die $Error if $Error;
208 ################################# calcdelta #################################
209 # Takes a date (year, month and day) and a time period (1d, 1w, 1m, 1y, ...)
210 # and adds the latter to the former
213 my ($Year, $Month, $Day, $Period) = @_;
214 my ($NYear, $NMonth, $NDay);
216 if ($Period =~ /(\d+)\s*([dw])/) { # Is counted in days or weeks: Use Add_Delta_Days.
217 ($NYear, $NMonth, $NDay) = Add_Delta_Days($Year, $Month, $Day, (($2 eq "w")?$1 * 7: $1 * 1));
218 } elsif ($Period =~ /(\d+)\s*([my])/) { #Is counted in months or years: Use Add_Delta_YM
219 ($NYear, $NMonth, $NDay) = Add_Delta_YM($Year, $Month, $Day, (($2 eq "m")?(0,$1):($1,0)));
221 return ($NYear, $NMonth, $NDay);
224 ################################ updatestatus ###############################
225 # Takes a MID and a status file name
226 # and writes status information to disk
229 my ($ActName, $File, $date, $MID) = @_;
231 print "$$ActName: Save status information.\n" if($Options{'v'});
233 open (FH, ">$$File.cfg") or die "$0: E: Can't open $$File.cfg: $!";
234 print FH "##;; Lastpost: $date\n";
235 print FH "##;; LastMID: $MID\n";
239 ################################## postfaq ##################################
240 # Takes a filename and many other vars.
242 # It reads the data-file $File and then posts the article.
245 my ($ActName,$File,$From,$Subject,$NG,$Fup2,$MIDF,$Charset,$ExtraHeaders,$Sender,$TDY,$TDM,$TDD,$ReplyTo,$Supersedes,$Expire) = @_;
246 my (@Header,@Body,$MID,$InRealBody,$LastModified);
248 print "$$ActName: Preparing to post.\n" if($Options{'v'});
251 $$TDM = ($$TDM < 10 && $$TDM !~ /^0/) ? "0" . $$TDM : $$TDM;
252 $$TDD = ($$TDD < 10 && $$TDD !~ /^0/) ? "0" . $$TDD : $$TDD;
253 my $Timestamp = time;
256 $MID = '<%n-%y-%m-%d@'.hostfqdn.'>' if !defined($MID); # set to default if unset
257 $MID =~ s/\%n/$$ActName/g;
258 $MID =~ s/\%d/$$TDD/g;
259 $MID =~ s/\%m/$$TDM/g;
260 $MID =~ s/\%y/$$TDY/g;
261 $MID =~ s/\%t/$Timestamp/g;
264 open (FH, "<$$File");
267 push (@Body, $_), next if $InRealBody;
268 $InRealBody++ if /^$/;
269 $LastModified = $1 if /^Last-modified:\s*(\S+)\s*$/i;
273 push @Body, "\n" if ($Body[-1] ne "\n");
275 #Create Date- and Expires-Header:
276 my @time = localtime;
277 my $ss = ($time[0]<10) ? "0" . $time[0] : $time[0];
278 my $mm = ($time[1]<10) ? "0" . $time[1] : $time[1];
279 my $hh = ($time[2]<10) ? "0" . $time[2] : $time[2];
281 my $month = ($time[4]+1<10) ? "0" . ($time[4]+1) : $time[4]+1;
282 my $monthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$time[4]];
283 my $wday = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat")[$time[6]];
284 my $year = (1900 + $time[5]);
285 my $tz = $time[8] ? " +0200" : " +0100";
287 $$Expire = '3m' if !$$Expire; # set default if unset: 3 month
289 my ($expY,$expM,$expD) = calcdelta ($year,$month,$day,$$Expire);
290 my $expmonthN = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")[$expM-1];
292 my $date = "$day $monthN $year " . $hh . ":" . $mm . ":" . $ss . $tz;
293 my $expdate = "$expD $expmonthN $expY $hh:$mm:$ss$tz";
295 #Replace %LM by the content of the news.answer-pseudo-header Last-modified:
297 $$Subject =~ s/\%LM/$LastModified/;
299 $$Subject =~ s/[<\[{\(]?\%LM[>\]}\)]?//;
303 my $ContentType = sprintf('text/plain; charset=%s',$Charset);
306 if($Options{'t'} and $Options{'t'} !~ /console/i) {
307 $$NG = $Options{'t'};
308 $MID =~ s/@/-$Timestamp-test@/g;
309 $$ExtraHeaders .= "\n" if $$ExtraHeaders;
310 $$ExtraHeaders .= "X-Supersedes: $$Supersedes\n" if $$Supersedes;
311 $$ExtraHeaders .= "X-yapfaq-Remark: This is only a test message.";
315 #Now create the complete Header:
316 push @Header, "From: $$From\n";
317 push @Header, "Newsgroups: $$NG\n";
318 push @Header, "Followup-To: $$Fup2\n" if $$Fup2;
319 push @Header, "Subject: $$Subject\n";
320 push @Header, "Message-ID: $MID\n";
321 push @Header, "Supersedes: $$Supersedes\n" if $$Supersedes;
322 push @Header, "Date: $date\n";
323 push @Header, "Expires: $expdate\n";
324 push @Header, "Sender: $$Sender\n" if $$Sender;
325 push @Header, "Mime-Version: 1.0\n";
326 push @Header, "Reply-To: $$ReplyTo\n" if $$ReplyTo;
327 push @Header, "Content-Type: $ContentType\n";
328 push @Header, "Content-Transfer-Encoding: 8bit\n";
329 push @Header, "User-Agent: yapfaq/$VERSION\n";
330 if ($$ExtraHeaders) {
331 push @Header, "$_\n" for (split /\n/, $$ExtraHeaders);
334 my @Article = (@Header, "\n", @Body);
337 print "$$ActName: Posting article ...\n" if($Options{'v'});
338 my $failure = post(\@Article);
341 print "$$ActName: Posting failed, ERROR.dat may have more information.\n" if($Options{'v'} && (!defined($Options{'t'}) || $Options{'t'} !~ /console/i));
343 updatestatus($ActName, $File, "$day.$month.$year", $MID) if !defined($Options{'t'});
347 ################################## post ##################################
348 # Takes a complete article (Header and Body).
350 # It opens a connection to $NNTPServer and posts the message.
356 # test mode - print article to console
357 if(defined($Options{'t'}) and $Options{'t'} =~ /console/i) {
358 print "-----BEGIN--------------------------------------------------\n";
360 print "------END---------------------------------------------------\n";
361 # pipe article to script
362 } elsif(defined($Options{'s'})) {
363 open (POST, "| $Options{'s'}") or die "$0: E: Cannot fork $Options{'s'}: $!\n";
364 print POST @$ArticleR;
369 warn "$0: W: $Options{'s'} exited with status ", ($? >> 8), "\n";
374 my $NewsConnection = Net::NNTP->new($Config{'NNTPServer'}, Reader => 1) or die "$0: E: Can't connect to news server '$Config{'NNTPServer'}'!\n";
375 $NewsConnection->authinfo ($Config{'NNTPUser'}, $Config{'NNTPPass'}) if (defined($Config{'NNTPUser'}));
376 $NewsConnection->post();
377 $NewsConnection->datasend (@$ArticleR);
378 $NewsConnection->dataend();
380 if ($NewsConnection->ok()) {
382 # Posting failed? Save to ERROR.dat
384 warn "$0: W: Posting failed!\n";
385 open FH, ">>ERROR.dat";
386 print FH "\nPosting failed! Saving to ERROR.dat. Response from news server:\n";
387 print FH $NewsConnection->code();
388 print FH $NewsConnection->message();
391 print FH "-" x 80, "\n";
394 $NewsConnection->quit();
401 ################################ Documentation #################################
405 yapfaq - Post Usenet FAQs I<(yet another postfaq)>
409 B<yapfaq> [B<-Vhvpd>] [B<-t> I<newsgroups> | CONSOLE] [B<-f> I<project name>] [B<-s> I<program>] [B<-c> I<.rc file>]
433 Furthermore you need access to a news server to actually post FAQs.
437 B<yapfaq> posts (one or more) FAQs to Usenet with a certain posting
438 frequency (every n days, weeks, months or years), adding all necessary
439 headers as defined in its config file (by default F<yapfaq.cfg>).
443 F<yapfaq.cfg> consists of one or more blocks, separated by C<=====> on
444 a single line, each containing the configuration for one FAQ as a set
445 of definitions in the form of I<param = value>. Everything after a "#"
446 sign is ignored so you may comment your configuration file.
450 =item B<Name> = I<project name>
452 A name referring to your FAQ, also used for generation of a Message-ID.
454 This value must be set.
456 =item B<File> = I<file name>
458 A file containing the message body of your FAQ and all pseudo headers
459 (subheaders in the news.answers style).
461 This value must be set.
463 =item B<Posting-frequency> = I<time period>
465 The posting frequency defines how often your FAQ will be posted.
466 B<yapfaq> will only post your FAQ if this period of time has passed
467 since the last posting.
469 You can declare that time period either in I<B<d>ays> or I<B<w>weeks>
470 or I<B<m>onths> or I<B<y>ears>.
472 This value must be set.
474 =item B<Expires> = I<time period> (optional)
476 The period of time after which your message will expire. An Expires
477 header will be calculated adding this time period to today's date.
479 You can declare this time period either in I<B<d>ays> or I<B<w>weeks>
480 or I<B<m>onths> or I<B<y>ears>.
482 This setting is optional; the default is 3 months.
484 =item B<From> = I<author>
486 The author of your FAQ as it will appear in the From header of the
489 This value must be set.
491 =item B<Subject> = I<subject>
493 The title of your FAQ as it will appear in the Subject header of the
496 You may use the special string C<%LM> which will be replaced with
497 the contents of the Last-Modified subheader in your I<File>.
499 This value must be set.
501 =item B<NGs> = I<newsgroups>
503 A comma-separated list of newsgroup(s) to post your FAQ to as it will
504 appear in the Newsgroups header of the message.
506 This value must be set.
508 =item B<Fup2> = I<newsgroup | poster> (optional)
510 A comma-separated list of newsgroup(s) or the special string I<poster>
511 as it will appear in the Followup-To header of the message.
513 This setting is optional.
515 =item B<MID-Format> = I<pattern> (optional)
517 A pattern from which the message ID is generated as it will appear in
518 the Message-ID header of the message.
520 You may use the special strings C<%n> for the I<Name> of your project,
521 C<%d> for the date the message is posted, C<%m> for the month, C<%y>
522 for the year and C<%t> for a time stamp (number of seconds since the
523 epoch), respectively.
525 This setting is optional; the default is '<%n-%y-%m-%d@I<YOURHOST>>'
526 where I<YOURHOST> is the fully qualified domain name (FQDN) of the
527 host B<yapfaq> is running on. Obviously that will only work if you
528 have defined a reasonable hostname that the hostfqdn() function of
529 Net::Domain can return.
531 =item B<Charset> = I<encoding> (optional)
533 The character encoding of your FAQ. This setting is optional, but
534 should match the encoding of your FAQ B<File>. Default is set to
537 This setting is copied verbatim to the I<Content-Type> header.
539 =item B<Supersede> = I<yes> (optional)
541 Add Supersedes header to the message containing the Message-ID header
544 This setting is optional; you should set it to yes or leave it out.
546 =item B<ExtraHeader> = I<additional headers> (optional)
548 The contents of I<ExtraHeader> is added verbatim to the headers of
549 your message so you can add custom headers like Approved.
551 This setting is optional.
555 =head3 Example configuration file
557 # name of your project
560 # file to post (complete body and pseudo-headers)
561 # ($File.cfg contains data on last posting and last MID)
564 # how often your project should be posted
565 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
566 Posting-frequency = '1d'
568 # time period after which the posting should expire
569 # use (d)ay OR (w)eek OR (m)onth OR (y)ear
573 From = 'test@domain.invalid'
576 # (may contain "%LM" which will be replaced by the contents of the
577 # Last-Modified pseudo header).
578 Subject = 'test noreply ignore'
580 # comma-separated list of newsgroup(s) to post to
581 # (header "Newsgroups:")
584 # header "Followup-To:"
587 # Message-ID ("%n" is $Name)
588 # MID-Format = '<%n-%d.%m.%y@domain.invalid>'
591 # This setting is optional. Default: UTF-8
592 # Charset = ISO-8859-15
594 # Supersede last posting?
597 # extra headers (appended verbatim)
598 # use this for custom headers like "Approved:"
599 ExtraHeader = 'Approved: moderator@domain.invalid
602 # other projects may follow separated with "====="
607 Posting-frequency = '2m'
608 From = 'My Name <my.name@domain.invalid>'
609 Subject = 'Test of yapfag <%LM>'
610 NGs = 'de.test,de.alt.test'
612 MID-Format = '<%n-%m.%y@domain.invalid>'
615 =head3 Status Information
617 Information about the last post and about how to form message IDs for
618 posts is stored in a file named F<I<project name>.cfg> which will be
619 generated if it does not exist. Each of those status files will
620 contain two lines, the first being the date of the last time the FAQ
621 was posted and the second being the message ID of that incarnation.
623 =head2 Runtime Configuration
625 Apart from configuring which FAQ(s) to post you may (re)set some
626 runtime configuration variables via the .rcfile (by default
627 F<.yapfaqrc>). F<.yapfaqrc> must contain one definition in the form of
628 I<param = value> on each line; everything after a "#" sign is ignored.
630 If you omit some settings they will be set to default values hardcoded
633 B<Please note that all parameter names are case-sensitive!>
637 =item B<NNTPServer> = I<NNTP server> (mandatory)
639 Host name of the NNTP server to post to. Must be set (or omitted; the
640 default is "localhost"); if set to en empty string, B<yapfaq> falls
641 back to Perl's build-in defaults (contents of environment variables
642 NNTPSERVER and NEWSHOST; if not set, default from Net::Config; if not
643 set, "news" is used).
645 =item B<NNTPUser> = I<user name> (optional)
647 User name used for authentication with the NNTP server (I<AUTHINFO
650 This setting is optional; if it is not set, I<NNTPPass> is ignored and
651 no authentication is tried.
653 =item B<NNTPPass> = I<password> (optional)
655 Password used for authentication with the NNTP server (I<AUTHINFO
658 This setting is optional; it must be set if I<NNTPUser> is present.
660 =item B<Sender> = I<Sender header> (optional)
662 The Sender header that will be added to every posted message.
664 This setting is optional.
666 =item B<ConfigFile> = I<configuration file> (mandatory)
668 The configuration file defining the FAQ(s) to post. Must be set (or
669 omitted; the default is "yapfaq.cfg").
671 =item B<Program> = I<file name> (optional)
673 A program the article is piped to instead of posting it to Usenet.
674 See option "-f" below (which takes preference).
676 This setting is optional.
680 =head3 Example runtime configuration file
682 NNTPServer = 'localhost'
686 ConfigFile = 'yapfaq.cfg'
689 =head3 Using more than one runtime configuration
691 You may use more than one runtime configuration file with the B<-c>
698 =item B<-V> (version)
700 Print out version and copyright information on B<yapfaq> and exit.
704 Print this man page and exit.
706 =item B<-v> (verbose)
708 Print out status information while running to STDOUT.
710 =item B<-p> (post unconditionally)
712 Post (all) FAQs unconditionally ignoring the posting frequency setting.
714 You may want to use this with the B<-f> option (see below).
716 =item B<-d> (dry run)
718 Start B<yapfaq> in simulation mode, i.e. don't post anything and don't
719 update any status information.
721 =item B<-t> I<newsgroup(s) | CONSOLE> (test)
723 Don't post to the newsgroups defined in F<yqpfaq.cfg>, but to the
724 (test) newsgroup(s) given after B<-t> as a comma-separated list or
725 print the FAQs to STDOUT separated by lines of dashes if the special
726 string C<CONSOLE> is given. This can be used to preview what
727 B<yapfaq> would do without embarassing yourself on Usenet.
729 The status files are not updated when this option is given.
731 When this option is used to post to some other newsgroup(s), a(nother)
732 timestamp is added to the Message-ID header and the Supersedes header
733 is replaced by a special X-Supersedes header.
735 You may want to use this with the B<-f> option (see below).
737 =item B<-f> I<project name>
739 Just deal with one FAQ only.
741 By default B<yapfaq> will work on all FAQs that are defined in
742 F<yapfaq.cfg>, check whether they are due for posting and - if they
743 are - post them. Consequently when the B<-p> option is set all FAQs
744 will be posted unconditionally. That may not be what you want to
745 achieve, so you can limit the operation of B<yapfaq> to the named FAQ
748 =item B<-s> I<program> (pipe to script)
750 Instead of posting the article(s) to Usenet pipe them to the external
751 I<program> on STDIN (which may post the article(s) then). A return
752 value of 0 will be considered success.
754 For example, you may want to use the I<inews> utility from the INN package
755 or the much more powerful replacement I<tinews.pl> from
756 I<ftp://ftp.tin.org/tin/tools/tinews.pl> which is able to sign postings.
758 If I<Program> is also defined in the runtime configuration file (by default
759 F<.yapfaqrc>), B<-s> takes preference.
761 =item B<-c> I<.rc file>
763 Load another runtime configuration file (.rc file) than F<.yaofaq.rc>.
765 You may for example define another usenet server to post your FAQ(s)
766 to or load another configuration file defining (an)other FAQ(s).
772 Just copy the contents of the tarball in some directory and get started.
774 You can post your first test with
776 yapfaq -c .yapfaqrc.sample
778 or copy F<.yapfaqrc.sample> to F<.yapfaqrc> and F<yapfaq.cfg.sample>
779 to F<yapfaq.cfg>, edit those files and get really started!
785 Post all FAQs that are due for posting:
789 Do a dry run, showing which FAQs would be posted:
793 Do a test run and print on STDOUT what the FAQ I<myfaq> would look
794 like when posted, regardless whether it is due for posting or not:
796 yapfaq -pt CONSOLE -f myfaq
798 Do a "real" test run and post the FAQ I<myfaq> to I<de.test>, but only
801 yapfaq -t de.test -f myfaq
803 Post all FAQs (that are due for posting) using inews from INN:
807 Do a dry run using a runtime configuration from .alternaterc, showing
808 which FAQs would be posted:
810 yapfaq -dvc .alternaterc
818 The default NNTP server to post to, used by the Net::NNTP module. You
819 can also specify the server using the runtime configuration file (by
820 default F<.yapfaqrc>).
834 Runtime configuration file for B<yapfaq>.
838 Configuration file for B<yapfaq>.
844 The status files will be created on successful posting if they don't
845 already exist. The first line of the file will be the date of the last
846 time the FAQ was posted and the second line will be the message ID of
847 the last post of that FAQ.
853 Please report any bugs or feature requests to the author or use the
854 bug tracker at L<https://bugs.th-h.de/>!
858 L<https://th-h.de/net/software/yapfaq/> will have the current
859 version of this program.
861 This program is maintained using the Git version control system. You
862 may clone L<git://code.th-h.de/usenet/yapfaq.git> to check out the
863 current development tree or browse it on the web via
864 L<https://code.th-h.de/?p=usenet/yapfaq.git>.
868 Thomas Hochstein <thh@inter.net>
870 Original author (up to version 0.5b, dating from 2003):
871 Marc Brockschmidt <marc@marcbrockschmidt.de>
873 =head1 COPYRIGHT AND LICENSE
875 Copyright (c) 2003 Marc Brockschmidt <marc@marcbrockschmidt.de>
877 Copyright (c) 2010-2017 Thomas Hochstein <thh@inter.net>
879 This program is free software; you may redistribute it and/or modify it
880 under the same terms as Perl itself.