Usenet Archive Binary Extraction Automation Tool

The following script can be used to extract and decode images from a Usenet binary archive created by Newsfetch. Newsfetch is free and runs in Unix. The source code for Newsfetch can be found here: ftp://sunsite.unc.edu/pub/Linux/system/news/readers/newsfetch-1.21.tar.gz

Example setup files for downloading train pictures can be found here: http://www.xmission.com/~georgeps/scripts.html

How could this be modified to deal with binhex and xxencode formatted data? -GPS

No need - UUDeview is a Tcl-based tool (written by Frank Pilhofer) that does all this and more. It's very well-written, thorough, flexible and robust. It includes an easy to use Tk interface. Very fast, too. (I once wrote a similar tool to do binary extraction so I really appreciate how good a job Frank did.) - Don Libes

The URL for UUDeview is: http://www.informatik.uni-frankfurt.de/~fp/uudeview/


 #!/usr/local/bin/tclsh8.3
 #This should work with tclsh > 8.0.5.
 #An earlier version of this had problems dealing with some filenames.

 set fp [open ./$argv r]
 set op 0

 set begin ""
 set end ""
 set prefix "/home/imagine/Trains/pics/"

 while {[eof $fp] != 1} \
 {
 set data [gets $fp]

        if {[regexp {\mbegin ([0-9]+) (.*)} $data all mode filename] == 1} \
        {
        puts "bef $filename"
        regsub -all { } $filename {} filename
        puts "aft $filename"
        set op [open ./_$filename w]
        set begin [tell $fp]
        }


        if {[regexp {\mend$} $data all]} {set end [tell $fp]}
        #Eventually I should check for a ` followed by end, to be more accurate.
        if {$end != "" && $begin == ""} {set end ""}

        if {$begin != "" && $end != ""} \
        {
        puts "filename $filename"
        puts "begin $begin"
        puts "end $end"
        seek $fp $begin
        puts $op "begin 644 $filename"
                while 1 \
                {
                puts $op [gets $fp]

                        if {$end < $begin} \
                        {
                        puts "Error: The end is before the beginning."
                        exit
                        }

                        if {[tell $fp] >= $end} \
                        {
                        set begin ""
                        set end ""
                        close $op
                        puts "$prefix$filename"
                        catch {exec uudecode -p _$filename > \
                        $prefix$filename}
                        catch {exec rm _$filename}
                        puts "done\n"
                        break
                        }

                }
        }
 }

See also http://brag.sf.net/ for another Tcl application for downloading and assembling multi-part binaries from newsgroups...