🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #3982

Re: Concatenate, uudecode in nn? [yet another script to do it]

#3982
From: Ian Phillipps
Date: Tue, 06 Apr 1993 12:55
90 lines
3471 bytes
nestabro@nova.gmi.edu (Noel Estabrook) writes:

>I _know you can concatenate and uudecode files in nn to save a lot of
>time, but how?  Can someone help?

Here's the script I use (there are lots more like this floating
around).  Mine has some pretty hairy heuristics in it, but I don't
know of any failures with actual postings. Assuming that you've an
appropriate sort option in place, you can pipe this the whole of,
say, comp.binaries.etc.etc and it will do the right thing.

(a) What do you mean, you don't have perl? Get it!
(b) Yes, I know perl can do uudecode, but I wrote this before it could.

---- cut here ---- (I resisted the temptation to uuencode this...)
#!/usr/bin/perl
# Attempt to join up uuencoded stuff
# Should work with most formats

$debug++ if $ARGV[0] eq '-d' && shift;
$rejects++ if $ARGV[0] eq '-r' && shift;
$stdout++ if $ARGV[0] eq '-t' && shift;

sub reject
{
    return unless $debug;
    print STDERR "Rejected ($_[0]): \"$_\"\n";
    print STDERR join(' ',unpack('c*',$_));
}

file:
    while(1)
    {
    #DEBUG# print stderr "file started";
    while(<>)
	{ $file=$1, last if /^begin +[0-9]* +([^ ]+)\n/ ; }
    exit if eof();
    print STDERR " $file\n";
    if ( $stdout )
	{ *OUT = *STDOUT; }
    else
	{ open( OUT, "|uudecode" ) || die "Can't do uudecode - " . $!; }
    #DEBUG# open( OUT, ">judout" ) || die "Can't do uudecode";
    print OUT $_;
line:
    while(<>)
	{
	# Deal with the usual case first, allowing for checksum/not
	if ( /^M/ && ( length($_) == 62 || length($_) == 63 ) )
	    { print OUT; next; };

	if( /^end/ )
	    {
	    print STDERR " .. closed" if $debug;
	    print OUT;
	    close OUT;
	    next file;
	    }

	( &reject(0), next ) unless /^[ -`]+.?\n$/;

	# Now some hairy heuristics
	$bytes = unpack('c',$_) - 32;
	$bytes = 0 if $bytes == 64;
	# Total number of chars expected including the prefix and newline
	$chars = int( ( $bytes + 2 )/3 )*4 + 2;

	print STDERR ">$_< $bytes $chars ",length($_),"\n" if $debug;
	( &reject(1) , next ) if $chars != length($_) && $chars != length($_)-1;
	( &reject(2), next ) if $chars > 61;
	( &reject(3), next ) if $chars < 0;
	( &reject(4), next ) if /^  +/;
	if ( /^ \n$/ )
	{
	    # This could be spurious, or a genuine penultimate line
	    $_ = <>;
	    print OUT " \n" if /^end/;
	    #DEBUG# print STDERR "Single blank followed by '$_'\n";
	    redo line;
	}
	print STDOUT "Short line: accepted $_\nUnpacked:",join(' ',unpack('c*',$_)) if $rejects;

	# OK but short
	print OUT $_;
	}
    }
-- 
Ian Phillipps, Unipalm Ltd, 216 Science Park,		Phone +44 223 420002
Milton Road, Cambridge, CB4 4WA, England.		Phax  +44 223 426868
PIPEX is a division of Unipalm Ltd. - phone 0223 424616.
Technical Details
Message-ID: <1993Apr6.125523.27260@unipalm.co.uk>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!newsserver.jvnc.net!yale.edu!yale!gumby!wupost!uunet!pipex!unipalm!ian
References: <nestabro.734094572@nova>

Show Full Headers
Complete Article Headers
Message-ID: <1993Apr6.125523.27260@unipalm.co.uk>
Subject: Re: Concatenate, uudecode in nn? [yet another script to do it]
Date: Tue, 6 Apr 1993 12:55:23 GMT
From: ian@unipalm.co.uk (Ian Phillipps)
References: <nestabro.734094572@nova>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!gmd.de!newsserver.jvnc.net!yale.edu!yale!gumby!wupost!uunet!pipex!unipalm!ian
Newsgroups: news.software.nn
Keywords: How? This way!
Organization: Unipalm Ltd., 216 Cambridge Science Park, Cambridge CB4 4WA, UK
Lines: 90