Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!caen!spool.mu.edu!agate!sunkist.berkeley.edu!raymond From: raymond@math.berkeley.edu (Raymond Chen) Newsgroups: comp.binaries.ibm.pc.d Subject: Re: msdos uploads to SIMTEL20 (update scripts) Message-ID: <1991Jun2.063300.22728@agate.berkeley.edu> Date: 2 Jun 91 06:33:00 GMT Article-I.D.: agate.1991Jun2.063300.22728 References: Sender: root@agate.berkeley.edu (Charlie Root) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Organization: U.C. Berkeley Lines: 323 In-Reply-To: w8sdz@WSMR-SIMTEL20.ARMY.MIL (Keith Petersen) Originator: raymond@sunkist.berkeley.edu The following scripts let you keep your local copy of the SIMTEL20 index up to date. To install, first get the SIMIBM.IDX file and rename it to SIMIBM.RAW. Now run simstart.pl. Copy the resulting SIMIBM.IDX file to C:\news\csip. (You can change the directory name by modifying the scripts.) That's the end of installation. To search the index, use the `lookup' script. This is essentially the same script that is used at the comp.sys.ibm.pc.misc archives. To update, save my update to a file and feed that file as stdin to the `simupd' script. The script places the updated index in SIMIBM.NEW. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'lookup.pl' <<'END_OF_FILE' X#!/usr/custom/bin/perl X# X# lookup: Looks up a word/phrase in various archive indexes X# X# downward compatible to perl version 2.0. X# X# Usage: X# X# lookup perl-expression X# X# Configuration: X# X# $limit = limit on amount of output generated X# $dir = directory where the indexes are kept X# X# Copyright 1991, Raymond Chen (rjc@math.princeton.edu) X# Distribution unrestricted, so long as you keep my name on it. X X$dir = "c:/news/csip"; X Xdie "usage: $0 word" if $#ARGV < $[; X Xif (1 != eval "sub match { $ARGV[0]; }1;") X { print "Malformed search criterion\n"; exit 1; } X X$limit = 400; # don't output more than this X$count = 0; # number of entries output so far X$marker = "\001"; # nonprintable inserted by simupd.pl X Xdo do_lookup("$dir/simibm.idx", "wsmr-SIMTEL20.army.mil"); X#do do_lookup("$dir/grape", "grape.ecs.clarkson.edu"); X#do do_lookup("$dir/garbo", "garbo.uwasa.fi"); X#do do_lookup("$dir/mm", "FidoNet node 2:515/1 (Micro Maniacs Opus)"); X Xsub do_lookup { X local($archive, $sitename) = @_; X X open(in, "<".$archive) || X open(in, "zcat $archive |") || X (print "Couldn't open $archive\n", return 0); X X $dir = $prevdir = ""; X X print "\nPrograms on $sitename matching your search criterion:\n\n"; X X while () { X if (/^~$/) { X $dir = ; X $_ = ; $_ = ; # skip two header lines X } X if (do match()) { X print $dir if $dir ne $prevdir; X $prevdir = $dir; X s/^$marker//o; X print; X do linecount(); X } X } X close(in); X} X Xsub linecount { X if ($count++ > $limit) { X print "... Output truncated due to excessive length.\n" . X " Try a more restrictive search string.\n"; X close(in); X exit 0; X } X} END_OF_FILE if test 1842 -ne `wc -c <'lookup.pl'`; then echo shar: \"'lookup.pl'\" unpacked with wrong size! fi # end of 'lookup.pl' fi if test -f 'simstart.pl' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'simstart.pl'\" else echo shar: Extracting \"'simstart.pl'\" \(915 characters\) sed "s/^X//" >'simstart.pl' <<'END_OF_FILE' X#!/usr/bin/perl X# X# simstart.pl X# X# Converts simibm.raw into a form that simtel.update and lookup can use. X# Xformat stdout = X@<<<<<<<<<<<< @<<@>>>>> @<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< X$file, $at,$size, $date, $comment X. X X$simfile = "simibm.raw"; X X$= = 0; # No automatic page breaks X Xopen(in, $simfile); # Open simibm.raw Xwhile () # Read one line X{ X ($dev,$dir,$file,$size,$type,$date,$comment) = X /^"(.*)","(.*)","(.*)",.*,(.*),(.),(.*),"(.*)"/; X $at = ($type == 8) ? "B" : "A"; X if ( $ldev ne $dev || $ldir ne $dir ) { # New page X print "~\nDirectory $dev$dir\n"; X print "Filename Type Length Date Description\n"; X print "===============================================================================\n"; X } X write; # Write the line X $ldev = $dev; X $ldir = $dir; X} X Xprint "~\n"; END_OF_FILE if test 915 -ne `wc -c <'simstart.pl'`; then echo shar: \"'simstart.pl'\" unpacked with wrong size! fi chmod +x 'simstart.pl' # end of 'simstart.pl' fi if test -f 'simupd.pl' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'simupd.pl'\" else echo shar: Extracting \"'simupd.pl'\" \(3769 characters\) sed "s/^X//" >'simupd.pl' <<'END_OF_FILE' X#!/usr/custom/bin/perl -s X# X# upd2.pl: Updates the master file from Raymond Chen's Monthly Postings X# X# Switches: X# -m = mark new files with Ctrl-A X# -n = don't compress the output X# X# Configuration: X# X# $dir = directory where the indexes are kept X# X# Copyright 1991, Raymond Chen (rjc@math.princeton.edu) X# Distribution unrestricted, so long as you keep my name on it. X X$directory_count = $undeleted = $unadded = $deleted = $added = 0; X X# if UNIX: X# $HOME = $ENV{"HOME"}; X# $dir = "$HOME/index"; X# X# if MSDOS: X$dir = "C:/news/csip"; X$n = 1; # don't compress in MS-DOS X X$simibm = "$dir/simibm.idx"; X$simnew = ">$dir/simibm.new"; X X$|=1; X Xunless (open(in, "<".$simibm)) { X $simnew = "| compress $simnew.Z" unless $n; X open(in, "zcat $simibm |") || die "Couldn't open $simibm"; X} X Xopen(out, $simnew) || "Couldn't open $simnew"; X X# Plan of attack: X# X# Start in state "skipping". X# X# Skipping: Read from <> until /^ Directory/. Save the directory name X# and call "find_directory". Then switch to state "matching". X# X# Matching: Read a filename from <>. X# If a header, then ignore it and stay in Matching mode. X# If the 15th character is not A or B, switch to Skipping. X# Otherwise call "find_match" to insert the guy. X X$added = $unchanged = $directory_count = 0; X$skipping = 1; X$prevline = ; # our peek-ahead buffer. X Xwhile ($skipping > 0) { X $skipping = do skip() if ($skipping == 1); X $skipping = do match() if ($skipping == 2); X} X X# skip: Skip to a new directory. Xsub skip { X while (<>) { X next unless /^ Directory/; X s/^ Directory.*(PD\d?:)/Directory $1/; X $dirname = $_; X return 2 * do find_directory(); X } X # if we get here, we've hit EOF. X return 0; X} X X# find_directory: Find the directory in $dirname, X# outputting the gunk we skipped over to get there. X Xsub find_directory { X chop($_ = $dirname); X print "\n$_" if !$q;# tell the user we're looking for a directory X print out $prevline; # output the tilde. X while () { X print out; # display the next line in the file. X next if ($_ ne $dirname); # blip past stuff we don't want. X X print out $_ = ; # blip the header X print out $_ = ; # blip the divider X $prevline = ; X $directory_count++; X return 1; # keep going X } X # if we get here, we've hit EOF. So complain. X print stderr "Couldn't find directory $dirname"; X $prevline = ""; X return 0; X} X Xsub match { X return 0 unless ($file = <>); X ($tag, $file) = split(//, $file, 2); X return 2 if $file =~ /^(Filename|==)/; X return 1 if substr($file,14,1) !~ /[AB]/; # first character is number zero X return 2 * do find_match(); X} X X# find-match: Filename to match is in $file. X Xsub find_match { X while ($prevline lt $file) { # while haven't found the right place X print out $prevline; # dump the previous line X return 0 unless $prevline = ; # get the next line X } X if ($prevline eq $file) { X if ($tag eq "-") { X $prevline = ""; # delete it X ++$deleted; X print "-" if !$q; X } else { X print "." if !$q; X ++$unadded; X } X return 1; X } else { X if ($tag eq "+") { X print out $file; # insert the new guy X print "+" if !$q; # let user know X ++$added; # bump the count. X } else { X print ":" if !$q; X ++$undeleted; X } X } X return 1; X} X X# cleanup X X Xprint "\n", X "$directory_count directories, ", X "$undeleted not deleted, ", X "$unadded not added, ", X "$deleted deleted, ", X "$added added.\n" if !$q; X Xprint out $prevline; Xprint out ; Xclose(in); X X$? = 0; close(out); X Xdie "Error writing output ($!)\n" if $?; END_OF_FILE if test 3769 -ne `wc -c <'simupd.pl'`; then echo shar: \"'simupd.pl'\" unpacked with wrong size! fi # end of 'simupd.pl' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0