Re: Usenet server test script
The script below is to get latest posts from a newsgroup via nntp.
It uses just bash.
If you post a message and run this script after few seconds I think
the probability of your message be the last is great.
In anyway the value of the var "REPLY" has more info than checked in the
script and, message ID, can be present.
Perhaps you would prefer get a list instead, sending with the script:
se "XOVER $[$LP-5]-$LP" 224
And selecting via the "ID" as said in your post.
Try play a bit with this; add echo $REPLY >&2 to see server's answer.
I don't have examples with SSL, only this one for plain text.
I'm not sure if this is what you wanted.
------------------
#!/bin/bash
S=194.177.96.26 # nntp.aioe.org
P=119
G=comp.unix.shell
e(){ exec 3<&-;exit 1;}
se(){ # send $1 expect $2
[ -n "$1" ]&&printf "$1\r\n" >&3
read<&3;[ "${REPLY%% *}" = "$2" ]||e
}
exec 3<>/dev/tcp/$S/$P||e
se '' 200
se "MODE READER" 200
se "GROUP $G" 211
LP=${REPLY% *};LP=${LP##* } # LP = latest post
[ -f /tmp/$G ]&&LL=$[`cat /tmp/$G`+1]||LL=$LP # LL = latest local
echo -e "LL=$LL\nLP=$LP" >&2
while [ $LP -ge $LL ];do
se "ARTICLE $LL" 220
[ -e /tmp/$G.$LL ]||while read -t 3;do [ "$REPLY" = .$'\r' ]&&break
echo "$REPLY"
#echo "${REPLY%?}" # \x0d cut
done <&3 >/tmp/$G.$LL
echo /tmp/$G.$LL >&2
echo $LL >/tmp/$G
LL=$[$LL+1]
done
e
--------------------
On Sun, 04 May 2008 10:37:18 -0300, Dave Farrance
<DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote:
> Below is a script that posts a test message via a public newserver and
> provides a randomly generated title and Message-ID. It uses the "rpost"
> command, which is included in the "suck" package to post the message.
>
> I'd like to add a "suck" command to the script to read the message back
> from the server, using the specified Message-ID, and to display that
> message. I guess I'll figure out how to do it eventually, but the "suck"
> command seems to be far more complex than "rpost" and it requires config
> files. There's no easy way to do this that I'm missing, is there?
>
>
> #!/bin/bash
> newsserver=aioe.cjb.net
> id=$(od -xvAn -N8 < /dev/urandom | tr -cd 0-9a-f)
> rpost $newsserver <<%end
> From: scriptpost <script@post.invalid>
> Newsgroups: alt.test
> Subject: TEST-$id
> Organization: scriptpost
> Message-ID: <$id@post.invalid>
>
> test $id
> %end
|