Discussion:
retrieve usenet article by message ID in terminal
(too old to reply)
Marco Moock
2024-02-04 14:23:29 UTC
Permalink
Hello!

Some weeks ago somebody posted a way to retrieve a complete message in
the terminal by the msg id.

Does somebody know where that has been posted?
--
kind regards
Marco

Spam und Werbung bitte an ***@nirvana.admins.ws
yeti
2024-02-04 18:05:11 UTC
Permalink
Post by Marco Moock
Hello!
Some weeks ago somebody posted a way to retrieve a complete message in
the terminal by the msg id.
Does somebody know where that has been posted?
No. I don't know.

...but this is one way that kind of does the trick:

------------------------------------------------------------------------
$ printf '%s\r\n' 'article <upo6l1$3k6a0$***@dont-email.me>' quit . | nc news.uni-stuttgart.de nntp
------------------------------------------------------------------------
--
I do not bite, I just want to play.
Olive S
2024-02-05 16:54:33 UTC
Permalink
Some weeks ago somebody posted a way to retrieve a complete message in the terminal by the msg id.
Note that this includes dot-stuffing, meaning lines beginning with a '.' are prefixed with one extra '.'.
My nc requires a port number, can't take a service name. It's 119 if others' nc are the same.
for line in io.stdin:lines() do
if line == "." then break end
if line:sub(1,1) == "." then
io.write(line:sub(2,-1).."\n")
else
io.write(line.."\n")
end
end
Wrote a little Lua script below, tested with LuaJIT.
If the stream errors out then it just throws a Lua assertion error.
I may make this into a more full-blast "newsget" for the fun of it.

One thing you highlighted I hadn't thought of before is pre-sending QUIT, pipelining it, before reading.
That feels like a very polite thing to do :)
local function nerr(s) io.stderr:write(s.."\n") os.exit(1) end
local function recvresp(stream)
return assert(stream:receive("*l")):match("^([0-9]+)[ \t]*(.-)[ \t]*$")
end
local msgid, host, port = ...
port = not port and 119 or tonumber(port)
if not (msgid and host and port) then
nerr("Usage: message-id host [port]")
end
local socket = require("socket") -- Lua Socket Library
local stream = assert(socket.connect(host, port))
local resp, line = recvresp(stream)
if resp ~= "200" and resp ~= "201" then
nerr("Fail: Server gave unhandled welcome: "..resp.." "..line)
end
assert(stream:send("ARTICLE "..msgid.."\r\n"))
stream:send("QUIT\r\n") stream:shutdown("send") -- don't care if this fails
local resp, line = recvresp(stream)
if resp == "220" then -- all good
elseif resp == "430" then
nerr("Fail: Message not found.")
else
-- Servers give a human-redable error description
-- which may be more specific than a client can come up with,
-- so it's best to just print it unless we can deal with it.
nerr("Fail: Server gave unhandled response: "..resp.." "..line)
end
-- 480: Authentication needed
-- Feel free to implement this yourself from RFC 4643
-- Easier is to pick a host that allows reading without auth.
-- 500: Server does not support ARTICLE
-- 501: Likely malformed message-id
for line in function() return assert(stream:receive("*l")) end do
if line == "." then break end
if line:sub(1,1) == "." then line = line:sub(2,-1) end
io.write(line.."\n")
end
stream:close()
Marco Moock
2024-02-06 09:02:53 UTC
Permalink
Post by yeti
nc news.uni-stuttgart.de nntp
That has the disadvantage that it includes the NNTP responses which
causes problem when parsed to other applications that expect only the
message.
--
kind regards
Marco

Send spam to ***@cartoonies.org
Marco Moock
2024-02-06 09:34:15 UTC
Permalink
Post by Marco Moock
Some weeks ago somebody posted a way to retrieve a complete message in
the terminal by the msg id.
Does somebody know where that has been posted?
lynx -source "nntp://news.i2pn2.org/<msgid>"
is nearly that what I need.
It places an <XMP>/</XMP> line at the beginning and at the end, but
sed can remove that.
--
kind regards
Marco

Send spam to ***@cartoonies.org
Adam W.
2024-02-23 15:47:34 UTC
Permalink
Post by Marco Moock
lynx -source "nntp://news.i2pn2.org/<msgid>"
Use '', otherwise $ in msgids will be treated as variables. At least in
bash.

Like in your msgid:

upsuen$qne4$***@dont-email.me

It's decoded to ***@dont-email.me, because there's no variable $qne4
and $1.
morena
2024-10-22 21:38:48 UTC
Permalink
Post by Marco Moock
Some weeks ago somebody posted a way to retrieve a complete message in
the terminal by the msg id.
Similar to yeti's line, in one line shell script, but like a pro
interactively asking for message id, shows message in less viewer.

------------------------------------------------------------------------

#!/bin/sh
function nsearch { read ID?"Message ID: "; printf "%s\r\n" "article
\$ID" quit . | nc news.blueworldhosting.com nntp | less; }; nsearch

------------------------------------------------------------------------
--
morena
gopher://morena.rip/
morena
2024-10-22 21:57:28 UTC
Permalink
A bit broken as somehow I expected newsreader client will respect my
newline ;/

You can see it at gopher://morena.rip/0ns or ideally get it as binary
with gopher://morena.rip/9ns as text can be always mangled over network
with newlines and things.
--
morena
gopher://morena.rip/
Loading...