#!/bin/csh # -------------- script for selective news/mail uqwk'ing # -------------- for Michael Leaver's PNR Palmtop News Reader # -------------- based on his "giveme" script # -------------- giveme.plw v 1.0 1st Oct 1996 # # -- This script allows you to download a subset of your # -- "normal" newsgroups -- or entirely different groups # -- plus it will allow you to add new groups on the fly # -- (for the current download only) # -- I've only tested this on one (Solaris) box, but it # -- should be very portable [I even used decent awk ;-) ] # -- If you have any trouble with this, please let me know # -- -Peter (peterw@clark.net) # -- # -- And a big THANK YOU to Michael ! @ TRUE = 1 @ FALSE = 0 # ------------------- user settings/prefs ------------------- # Where is your newsrc set NEWSRC = $HOME/.newsrc # Set username # XXX What is your username? set ZUNAME=peterw # XXX Change this - it could be /usr/mail/[your username] # XXX or /usr/spool/mail/[your username] set MY_MAILBOX = /var/mail/$ZUNAME # Do you want to end up with a modified newsrc (TRUE) # or would you rather have newsrc not know anything happened (FALSE)? set MODIFY_NEWSRC = $TRUE # Do you want to remove the mail from your mail box (TRUE) # or leave it on the UNIX host _as well as_ d/l a copy (FALSE) set REMOVE_MAIL = $FALSE # OK, these are the groups I want sent to PNR # These are space-delimited. Nota Bene: I think sed # will interpret the "."'s as single-character wildcards set PNR_GROUPS = "alt.comp.sys.palmtops.hp comp.infosystems.www.servers.unix comp.os.linux.announce" # ---------------------done with settings -------------------- cp $NEWSRC ./newsrc.save.$$ echo Removing old uqwk files set UQWK_EXTS = "idx jn mai nws" foreach EXT ( $UQWK_EXTS ) rm -f $ZUNAME.$EXT end # Let's find what groups you are subscribed to # This builds a command file for sed to re-subscribe later grep ':' $NEWSRC | awk ' BEGIN {FS=":"} {print $1"\!/"$1":"}' | sed 's:^:s/:g' | sed 's:$:/g:g' > sed.$$ # Let's un-subscribe everything sed 's/:/\!/g' < $NEWSRC > a.$$ ; mv a.$$ $NEWSRC # And now well re-subscribe to PNR_GROUPS foreach PNR_GRP ( $PNR_GROUPS ) echo "Subscribing to "$PNR_GRP sed "s/\$PNR_GRP\!/\$PNR_GRP\:/g" <$NEWSRC > a.$$ ; mv a.$$ $NEWSRC end # Would you like any fries with that another: echo 'Another newsgroup [n]' set INPUT_STUFF = $< if ( $INPUT_STUFF == "" ) then goto done endif set MATCHES = `grep "^$INPUT_STUFF\!" $NEWSRC` if ( $#MATCHES > 0 ) then sed "s/\$INPUT_STUFF\!/\$INPUT_STUFF\:/g" <$NEWSRC > a.$$ ; mv a.$$ $NEWSRC echo 's/'$INPUT_STUFF':/'$INPUT_STUFF'\!/g' >> redosed.$$ else set CMATCHES = `grep "^$INPUT_STUFF\:" $NEWSRC` if ( $#CMATCHES > 0 ) then echo 'Already subscribed' else echo 'Not a valid newsgroup according to .newrsc ' endif endif goto another done: # And now you would do the normal "giveme" stuff # Get the news in the format required cp $NEWSRC .newsrc cp $MY_MAILBOX ./$ZUNAME echo Getting news... # -----ZipNews # XXX -B3500 means get 3500 blocks maximum # I do news & mail separately so I can put the mail # on my "proper" desktop when at home -PW if ( $REMOVE_MAIL == $FALSE ) then # Here: do news, no mail, please modify .newsrc uqwk +n -m -r +z -B3500 -H$PWD # And here: do mail, no news, leave mail on server uqwk +m -n +r +z -B3500 -H$PWD else uqwk +n +m -r +z -B3500 -H$PWD endif mv .newsrc $NEWSRC rm ./$ZUNAME # I dunno if you subscribed to those Anothers or not if (-e redosed.$$ ) then sed -f redosed.$$ <$NEWSRC >a.$$ ; mv a.$$ $NEWSRC endif # Now we can re-susbcribe to your normal groups sed -f sed.$$ <$NEWSRC > a.$$ ; mv a.$$ $NEWSRC if ( $MODIFY_NEWSRC == $FALSE ) then cp newsrc.save.$$ $NEWSRC endif # Clean up the temp files rm *.$$ # Download file # XXX Do you have zip on your host (UNIX) system? # zip $ZUNAME.zip $ZUNAME.* # XXX Z-modem (sz) or X-modem (sx) ? # sz $ZUNAME.zip echo All done