🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #52543

Re: Where the heck can I find info on (or an alternative to) inews?

#52543
From: An Unspecified Meowbot
Date: Sun, 27 May 2001 20:11
149 lines
5464 bytes
Louis LeBlanc <leblanc-nospam@acadia.nospam.mediaone.net> wrote:

> Hey all.  I am having trouble posting with inews.  For some stupid
> reason it keeps telling me it can't get the list of newsgroups.  my
> other apps are having NO trouble with this, so I am getting annoyed.

You have INN's inews installed without the rest of INN.  Lose it and
instead use oner of the mini-inews variants.

> Is there any place that documents the inews program 

man inews is supposed to work =)

> or has an alternative to a quick, fast posting only program?

#!/usr/bin/env python
"""inews - send a stream or file to an NNTP server using POST.

The article will be posted to the server specified in the NNTPSERVER
environment variable, or localhost if that is not defined.

If you have a file called .authinfo in your home directory, you can use it
to supply username/password info to the server.  The format is just:

    # this is a comment
    news1.example.com username password
    news2.example.com anotherusername anotherpassword

This program was automatically generated by an unspecified meowbot
and dumped into the public domain as part of an ongoing effort to
pollute the public consciousness.  Meow.
"""

import os, os.path, sys, string, getopt, socket, nntplib
from cStringIO import StringIO

if sys.version[0:5] < '1.5.2':
    sys.stderr.write('%s: Python 1.5.2 or newer required\n' % sys.argv[0])
    sys.exit(1)


def usage(errmsg):
    sys.stderr.write('%s: %s\nUsage: inews [-?][-D1|2][-N][-S] [article]\n'
                     % (sys.argv[0], errmsg))

def showhelp():
    print sys.argv[0], """options:

  -?:      display this message.
  -S:      Don't append $HOME/.signature to the article.
  -D, -D1: show some Debug information.
  -D2:     show lots of Debug information.
  -N       No posting, just display for testing.
"""

def getauth(servername):
    authfile = os.path.join(os.getenv('HOME'), ".authinfo")
    authuser = ""
    authpass = ""
    try:
        F = open(authfile)
    except:
       # try to plug along without authinfo
       return (authuser, authpass)
    for line in F.readlines():
        fields = string.split(string.strip(line))
        if fields[0][:1] == "#":
            continue
        if string.lower(fields[0]) == string.lower(servername):
            if len(fields) > 1:
                authuser = fields[1]
            if len(fields) > 2:
                authpass = fields[2]
            break
    return (authuser, authpass)

try:
    NNTPSERVER = os.environ['NNTPSERVER']
except KeyError:
    NNTPSERVER = 'localhost'
debug = nopost = verbose = 0
signature = 1
try:
    optlist, args = getopt.getopt(sys.argv[1:], '?D:NShv')
except:
    usage(sys.exc_info()[1])
    sys.exit(1)

for (o, v) in optlist:
    if o == '-D':
        if v in ('1', '2'):
            debug = v
        else:
            usage('Invalid debug level: '+ repr(v))
            sys.exit(1)
    elif o == '-N':
        nopost = 1
    elif o == '-S':
        signature = 0
    elif o == '-h':  # for compatibility
        pass
    elif o == '-?':
        showhelp()
        sys.exit(0)

if len(args) > 1:
    usage('More than one filename supplied')
    sys.exit(1)
elif len(args) == 0:
    artfile = sys.stdin
else:
    try:
        artfile = open(args[0], 'r')
    except:
        sys.stderr.write( "%s: %s: %s\n" % (sys.argv[0], args[0],
                                            sys.exc_info()[1]))
        sys.exit(2)
if debug:
    print artfile

artout = StringIO()
artout.write(artfile.read())

if signature:
    sigfile = os.environ['HOME'] + '/.signature'
    try:
        sigfh = open(sigfile, 'r')
        artout.write("\n-- \n" + sigfh.read())
        sigfh.close()
    except:
        pass

artout.seek(0)
if nopost:
    sys.stdout.write(artout.read())
else:
    (authuser, authpass) = getauth(NNTPSERVER)
    remote = nntplib.NNTP(NNTPSERVER)
    remote.set_debuglevel(debug)
    try:
        remote.shortcmd("mode reader")
    except nntplib.error_perm:
        pass
    if authuser:
        resp = remote.shortcmd("authinfo user %s" % authuser)
        if resp[0] == "3" and authpass:
                remote.shortcmd("authinfo pass %s" % authpass)
    remote.post(artout)
Technical Details
Message-ID: <87u226h7rr.fsf@adsl-141-154-22-77.bostma.adsl.bellatlantic.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!news.supernews.com!not-for-mail
References: <3B111B95.AB92748C@acadia.nospam.mediaone.net>

Show Full Headers
Complete Article Headers
Message-ID: <87u226h7rr.fsf@adsl-141-154-22-77.bostma.adsl.bellatlantic.net>
Subject: Re: Where the heck can I find info on (or an alternative to) inews?
Date: Sun, 27 May 2001 20:11:20 +0000
From: An Unspecified Meowbot <meowbot@meowing.net>
References: <3B111B95.AB92748C@acadia.nospam.mediaone.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!sn-xit-01!sn-post-01!supernews.com!news.supernews.com!not-for-mail
Newsgroups: news.software.nntp
Organization: They
Mail-Copies-To: nobody
X-Meow: Wouf
X-Face: #!n`o'kqzEiF(\CL4IR$H.F-||!S*5wv~g8~prn}Z<+F/-^?oJ:#_V#QP?G}!!yayV0]i\'
 GTb6:]Tic*!vjH}wm>ILhZBn8U0XEjh'l~yrjB?4Iiph5N9:kwqd/}86UTr9i|LCu]Bd)~G1R9U(qJ
 KOyEQK8*?
User-Agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Cuyahoga Valley)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: newsabuse@supernews.com
Lines: 148