Re: Usenet server test script
The carbonbased lifeform Dave Farrance inspired comp.unix.shell with:
> "Theo v. Werkhoven" <theo@van-werkhoven.nl.invalid> wrote:
>
>>Sure there is.
>>$telnet news.xs4all.nl 119
>>Trying 194.109.133.242...
>>Connected to news.xs4all.nl.
>>Escape character is '^]'.
>>200 news.xs4all.nl NNRP Service Ready (posting ok).
>>article <l3kr14d2fhvghmla9rdh0ia12cupsq2fqs@4ax.com> /* my command */
>>220 0 <l3kr14d2fhvghmla9rdh0ia12cupsq2fqs@4ax.com> article
>>Path: news.xs4all.nl!newsspool.news.xs4all.nl!newsfeed.x s4all.nl...
>>...
>>With 'article' you get the post with the requested Message-ID.
>>Now write a little expect script and you're done.
>
> Thanks for the reply. I've installed tcp and expect, but I find the
> expect manpage to be hard reading. I've managed to get it to display a
> post, although I don't really know how to separate the server messages
> from the post. The "interact" tells it to display everything, and it
> does exit without user intervention, but I'm sure there's a neater way.
You're right, expect(1) /is/ difficult to read if you have no
experience with expect yet.
With 'body' instead of 'article' it skips the headers. Is that what you
mean by 'server messages'?
>
> #!/usr/bin/expect -f
> spawn telnet aioe.cjb.net 119
> sleep 1
> send "article <0123456789abcdef@foo.invalid>\r"
> sleep 1
> send "quit\r"
> interact
Put this in a script called e.g. 'newsbody.exp' and make it executable
#v+
!/usr/bin/expect --
spawn telnet [lindex $argv 0 ] 119
expect -re "200(.*)$"
send "body [lindex $argv 1]\r"
expect -timeout 1 -re "^\.$"
send "quit\r"
#v-
Use as:
newsbody.exp "server.address.tld" "Message_ID" >testout.txt
Theo
--
theo at van-werkhoven.nl ICQ:277217131 SuSE Linux
linuxcounter.org: 99872 Jabber:muadib at jabber.xs4all.nl AMD XP3000+ 1024MB
"ik _heb_ niets tegen Microsoft, ik heb iets tegen
de uitwassen *van* Microsoft"
|