🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #70048

Re: NNTP server test script

#70048
From: Conrad J. Sabatier
Date: Sat, 02 Oct 2004 00:49
82 lines
3404 bytes
In article <2Sm7d.12534$Hz.12393@fed1read04>,
Conrad J. Sabatier <conrads@cox.net> wrote:
>
>
>In article <hTJRc.8593$_C6.863@cyclops.nntpserver.com>,
>John Kenickney <spam.trap@bigfoot.com> wrote:
>>
>>
>>I want to test free nntp servers that I find on the internet. Mostly the
>>reports are not correct; they don't exist anymore or they don't allow
>>posting anymore... It's a time consuming job to do that by hand with an
>>ordinary news reader. Is there a script or program that tests whether a
>>server allows posting or at least tries to post a test message?
>
>You can do this with the bash shell, using its i/o redirection facilities to 
>create a tcp connection to the server.  Here's an example "post" script:
>
>#!/usr/local/bin/bash
>#
># usage: post article server
>#
># where "article" is the filename of the article to be posted
># should contain, at a minimum, Newsgroups:, Subject: and From: header lines
>#
># server is, of course, the address of the server to post to
>
>article=$1
>server=$2
>
># avoid any line-splitting of server's replies
>IFS=""
>
># loop until a connection is established
>while true
>do
>	exec < /dev/tcp/${server}/nntp && read -r && [ "${REPLY%% *}" == "200"
>] && break
>done

One small potential problem, I just realized, with the above statement.  
This will loop forever if the server returns a "201" (no posting allowed) 
instead of "200" (posting allowed).

Modify accordingly.

Still, pretty amazing what you can do with a relatively simple little bash 
script, isn't it?  :-)

>#send post command, check server's reply
>echo -e "post\r" >&0
>read -r
>if [ "${REPLY%% *}" != "340" ]
>then
>	# echo the server's reply and exit if not OK to post
>	echo -E $REPLY >&2
>	echo -e "quit\r" >&0
>	read -r
>	exit 1
>fi
>
># send the article
>cat $article >&0
>echo -e "\r\n.\r" >&0
>
># check the server's reply
>read -r
>if [ "${REPLY%% *}" != "240" ]
>then
>	# echo the server's reply and exit if not "article posted"
>	echo -E $REPLY >&2
>	echo -e "quit\r" >&0
>	read -r
>	exit 1
>fi
>
># do a clean exit
>echo -e "quit\r" >&0
>read -r
>exit 0

-- 
Conrad J. Sabatier <conrads@cox.net> -- "In Unix veritas"
Technical Details
Message-ID: <qWm7d.12536$Hz.9114@fed1read04>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!fed1read04.POSTED!53ab2750!not-for-mail
References: <hTJRc.8593$_C6.863@cyclops.nntpserver.com> <2Sm7d.12534$Hz.12393@fed1read04>

Show Full Headers
Complete Article Headers
Message-ID: <qWm7d.12536$Hz.9114@fed1read04>
Subject: Re: NNTP server test script
Date: Sat, 02 Oct 2004 00:49:26 GMT
From: conrads@cox.net (Conrad J. Sabatier)
References: <hTJRc.8593$_C6.863@cyclops.nntpserver.com> <2Sm7d.12534$Hz.12393@fed1read04>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!newsfeed.wirehub.nl!newsfeed00.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!p01!fed1read04.POSTED!53ab2750!not-for-mail
Newsgroups: news.software.nntp
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
Originator: conrads@cox.net (Conrad J. Sabatier)
Lines: 82
NNTP-Posting-Host: 68.11.71.51
X-Complaints-To: abuse@cox.net
X-Trace: fed1read04 1096678166 68.11.71.51 (Fri, 01 Oct 2004 20:49:26 EDT)
NNTP-Posting-Date: Fri, 01 Oct 2004 20:49:26 EDT
Organization: Cox Communications