Article View: news.software.readers
Article #46079Re: [slrn] Saving new/unread articles?
From: to... tony summerfelt
Date: Sat, 23 Jan 1999 00:00
Date: Sat, 23 Jan 1999 00:00
158 lines
4938 bytes
4938 bytes
On Sat, 23 Jan 1999 06:02:10 GMT, ras2 wrote:
> Odd situation: For rather obscure reasons, I want to save all
> new posts in a certain group to a file, preferably without
> even entering the group, i.e. I need to archive the posts,
i use this macro that i modified from another in the docs iirc. the perl
program following it will save them to the appropriate directories (assuming
they exist (you could change the perl program to make them if you like. i'm
using slrnpull so i don't have to worry about that, but the rkive.sl macro
will work without slrnpull...
you'd have to make sure your directories between the two programs are in
sync...
you'll need another macro to make them all read once all the articles are
re-written...
this will archive your groups:
==========================================================================
%rkive.sl
define append_to_file ()
{
ERROR_BLOCK
{
_clear_error ();
}
set_input_string ("~/unread.nws");
call ("save");
}
define save_unread ()
{
if (is_group_mode ()) return;
variable msgid = extract_article_header ("Message-ID");
variable is_collapsed = is_thread_collapsed ();
EXIT_BLOCK
{
set_input_string (msgid);
call ("locate_header_by_msgid");
if (is_collapsed) collapse_thread ();
}
call ("header_bob");
do
{
if (is_thread_collapsed ())
{
uncollapse_thread ();
loop (thread_size () - 1)
{
!if (get_header_flags () & HEADER_READ)
append_to_file ();
() = header_down (1);
}
!if (get_header_flags () & HEADER_READ)
append_to_file ();
collapse_thread ();
}
else
!if (get_header_flags () & HEADER_READ)
append_to_file ();
}
while (header_down (1));
}
define loop_groups ()
{
call ("bob");
do
{
call ("select_group");
save_unread ();
call ("quit");
}
while (group_down_n (1));
}
definekey ("loop_groups", "R", "group");
==========================================================================
#!/usr/bin/perl
#unrkive.pl this will unarchive.
$basedir="/var/spool/news/";
$newsarchive="~/unread.nws";
$count=0;
open (unread,"$newsarchive") || die "\"$newsarchive\" -- $!";
print "\nrestoring unread news from $newsarchive\n\n";
while(<unread>)
{
$from=$_ if /^from/i;
if (/^newsgroups/i)
{
$count++;
$newsdir=$_;
$newsgroups=$_;
$newsdir=~s/\./\//g;
$newsdir=~s/^newsgroups:\s+//i;
$newsdir=~s/\s+$//;
@newsdir=split(/,/,$newsdir);
foreach $newsdir (@newsdir)
{
$newsdir=$basedir.$newsdir;
if (-d $newsdir)
{
print "$count: [newsgroup] $newsdir\n";
# get list of existing articles
opendir(dir, $newsdir);
@articles = sort grep(/\d+/, readdir(dir));
closedir(dir);
# set next article number
$min=$articles[0];
@articles=reverse(@articles);
$max=$articles[0];
$article=$max;
$article++;
open (minmax,">$newsdir/\.minmax")
|| die "\".minmax\" -- $!";
print minmax "$min $max\n";
truncate("$newsdir/\.overview",0);
open (msgline,">$newsdir/$article")
|| die "\"$article\" -- $!";
print msgline "$from";
}
}
}
print msgline $_;
}
print "\n$count articles restored from $newsarchive\n";
--
t
*-------------------------------------------------------------------------
| origin: ...the vented spleen kingston on (613-544-9332) 1:249/139
|
| `you want a toe? i can get you a toe'
|
| take myspleen out to reply via email
*-------------------------------------
Technical Details
Message-ID:
<36aaa085.0@news.kosone.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mailReferences:
<CBdq2.114$yk7.461@news.get2net.dk>Show Full Headers
Complete Article Headers
Message-ID: <36aaa085.0@news.kosone.com> Subject: Re: [slrn] Saving new/unread articles? Date: Sat, 23 Jan 1999 00:00:00 +0000 From: to...@myspleen.kos.net (tony summerfelt) References: <CBdq2.114$yk7.461@news.get2net.dk> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp!not-for-mail X-Deja-AN: 436207100 X-Trace: newsfeed.slurp.net 917152470 199.246.3.130 (Sat, 23 Jan 1999 22:34:30 CDT) Organization: Kingston Online Services User-Agent: slrn/0.9.5.4 (UNIX) Reply-To: to...@myspleenkos.net NNTP-Posting-Date: Sat, 23 Jan 1999 22:34:30 CDT Newsgroups: news.software.readers,alt.lang.s-lang