Article View: news.software.readers
Article #8999Re: How to use several NNTP servers (Re: A real
From: Leif Johansson
Date: Thu, 12 May 1994 12:02
Date: Thu, 12 May 1994 12:02
226 lines
6600 bytes
6600 bytes
In article L6NojK54O194058yn@uta.fi, samik@uta.fi (Sami K|ykk{) writes:
>
>You should have a different .newsrc file for every NNTP server you are
>going to use.
I have a script that does this and keeps track of what newsreader to use (You
might not whant to use xvnews when phoning in...) It goes something like this:
Please note that this is highly experimental. The script does no locking on files
and is therefore a bit unsafe. I have used it for a couple of weeks now with no
sideeffects (If you use only this - don't start a newsreader separately!). When
I get the time I will rewrite this in perl with a bit more safety and bells&whistles.
Also: don't quit using ^C or ^Z. The script does a bit of cleaning up after you
exit the newsreader....
NOTE: I don't support this in any way. Use it at your own risk. Read the script
to get documentation. :-)
There are a two config files: $HOME/.vnrc and $HOME/.nntphosts. I include
samples:
.vnrc:
_______________ CUT _________________
timeout 10
sun4c.tty /usr/local/bin/tin -r
sun4c.x xvnews
sun4m.tty /usr/local/bin/tin -r
sun4m.x xvnews
sun4d.tty /usr/local/bin/tin -r
sun4d.x xvnews
alpha.tty tin -r
alpha.x xterm -e 'tin -r'
_______________ CUT __________________
.nntphosts:
_______________CUT ____________________
news.kth.se
news.matematik.su.se
news.su.se default
______________ CUT ______________________
vn:
______________ CUT _____________________
#!/bin/sh
#
# Virtual newsreader. Adapts to the situation at hand.
#
# Set up defaults if no local config files exists
if [ -f $HOME/.nntphosts ]; then
NNTPHOSTS=$HOME/.nntphosts
else
NNTPHOSTS=/usr/local/etc/nntphosts
fi
export NNTPHOSTS
if [ -f $HOME/.vnrc ]; then
VNRC=$HOME/.vnrc
else
VNRC=/usr/local/etc/vnrc
fi
export VNRC
NEWSRC=$HOME/.newsrc
export NEWSRC
# I don't check if the actual port 119 has anything on it.
# This will be in the next perlified version. Thus the following:
PING="/usr/etc/ping"
export PING
#
# Change nothing below this line
#
if [ ! -f $NNTPHOSTS ]; then
echo "No .nntphosts file"
exit 1
else
DEFNNTP=`grep default $NNTPHOSTS | awk ' { print $1 } '`
export DEFNNTP
fi
if [ $# -gt 0 ]; then
case $1 in
'-i')
DEFNNTP=""
export DEFNNTP
;;
'-v')
echo "vn version 0.0000001alfa (c) Leif Johansson Distibute Freely"
exit 0
;;
esac
fi
if [ ! -f $VNRC ]; then
TIMEOUT=20
export TIMEOUT
TTYN="tin -r"
export TTYN
XN="xvnews"
export XN
else
TIMEOUT=`grep timeout $VNRC | awk ' { print $2 } '`
export TIMEOUT
MACH=`uname -m`
export MACH
if [ x`grep $MACH.tty $VNRC | awk ' { print $1 } '` != x ]; then
TTYN=`grep $MACH.tty $VNRC | awk ' { for (i = 2; i <= NF; ++i) print $i } '`
export TTYN
else
echo "Warning: No tty newsreader for this architechture: " $MACH
fi
if [ x`grep $MACH.x $VNRC | awk ' { print $1 } '` != x ]; then
XN=`grep $MACH.x $VNRC | awk ' { for (i = 2; i <= NF; ++i) print $i } '`
export XN
else
echo "Warning: No X newsreader for this architechture: " $MACH
fi
fi
if [ ! -x $PING ]; then
echo $PING "not executable"
exit 1
fi
#
# Enough startup! Here we go!
#
for x in `cat $NNTPHOSTS | awk ' { print $1 } '`
do
if [ ! -f $NEWSRC.$x ]; then
touch $NEWSRC.$x
echo "Making empty" .newsrc.$x " file"
fi
done
if [ x$DEFNNTP != x ]; then
if [ x`$PING $DEFNNTP $TIMEOUT | awk ' { print $3 } '` = xalive ]; then
echo "Your favorite nntpserver is up and kicking."
NNTPSERVER=$DEFNNTP
export NNTPSERVER
if [ -f $NEWSRC.$NNTPSERVER ]; then
cp $NEWSRC.$NNTPSERVER $NEWSRC
else
echo "No .newsrc file for this host."
echo "Creating an empty one...."
touch $NEWSRC.$NNTPSERVER
cp $NEWSRC.$NNTPSERVER $NEWSRC
fi;
if [ x$DISPLAY = x ]; then
$TTYN
else
$XN
fi;
cp $NEWSRC $NEWSRC.$NNTPSERVER
exit 0
else
echo "Your favorite nntpserver doesn't answer ..."
echo "Trying other nntpservers ..."
fi
fi
echo "Alive nntp hosts known to me are ..."
while true
do
for x in `cat $NNTPHOSTS | awk ' { print $1 } '`
do
if [ x`$PING $x $TIMEOUT | awk ' { print $3 } '` = xalive ]; then
echo $x
echo 'What now [(c)onnect,(n)next in list,(q)uit]?' | tr -d '\012'
read reply
reply=`echo "${reply}" | tr -d ' \011'`
case "X${reply}" in
X[cC]*)
NNTPSERVER=$x
export NNTPSERVER
if [ -f $NEWSRC.$NNTPSERVER ]; then
cp $NEWSRC.$NNTPSERVER $NEWSRC
else
echo "No .newsrc file for this host."
echo "Creating an empty one...."
touch $NEWSRC.$NNTPSERVER
cp $NEWSRC.$NNTPSERVER $NEWSRC
fi;
if [ x$DISPLAY = x ]; then
$TTYN
else
$XN
fi
cp $NEWSRC $NEWSRC.$NNTPSERVER
exit 0
;;
X[nN]*)
echo "Trying next..."
;;
X[qQ]*)
echo "See you later."
exit 0
;;
esac
fi
done
echo "No more nntphosts in " $NNTPHOSTS " ."
echo "Starting over..."
done
fi
_________________CUT _______________________
Leif Johansson Phone: +46 8 164541
Department of Mathematics Fax : +46 8 6126717
Stockholm University email: leifj@matematik.su.se
<This space is left blank for quotational and disclamatory purposes.>
Technical Details
Message-ID:
<2qt5t3$gno@vanfp4.physto.se>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!nntp.gmd.de!Germany.EU.net!EU.net!sunic!trane.uninett.no!nac.no!news.kth.se!news.physto.se!wizkids!leifjReferences:
<L6NojK54O194058yn@uta.fi>Show Full Headers
Complete Article Headers
Message-ID: <2qt5t3$gno@vanfp4.physto.se> Subject: Re: How to use several NNTP servers (Re: A real Date: Thu, 12 May 1994 12:02:43 +0000 From: leifj@matematik.su.se (Leif Johansson) References: <L6NojK54O194058yn@uta.fi> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!nntp.gmd.de!Germany.EU.net!EU.net!sunic!trane.uninett.no!nac.no!news.kth.se!news.physto.se!wizkids!leifj Newsgroups: news.software.readers Organization: Matematiska institutionen vid Stockholms Universitet Lines: 227 Distribution: world Reply-To: leifj@matematik.su.se NNTP-Posting-Host: wizkids.matematik.su.se Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit