/usr/bin/postnews is in postnews 0.5.3-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #!/usr/bin/python
# postnews 0.5.3 - post a usenet article
#
# (C) 2001 by Michael Waschbuesch <waschbuesch@users.sourceforge.net>
# http://sourceforge.net/projects/postnews/
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# Juhuu! Mein erstes Python-Programm :o)
import sys
import nntplib
import getopt
def main():
#get arguments and options
try:
opts, args = getopt.getopt(sys.argv[1:], "hf:p:vr", ["help", "file=", "port=", "user=", "pass=", "verbose", "readermode"])
except:
usage()
sys.exit(2)
#parse arguments
if len(args) !=1:
usage()
sys.exit(2)
server = args[0];
#parse options
file = sys.stdin
port = 119
user = ""
password = ""
verbose = 0
readermode = None
for o, a in opts:
if o in ("-h", "--help"):
usage()
sys.exit()
if o in ("-f", "--file"):
try:
file = open(a)
except IOError:
sys.stderr.write("File not found: "+a+"\n")
sys.exit(2)
if o in ("-p", "--port"):
try:
port = int(a)
if port < 0 or port > 65535:
raise ValueError
except ValueError:
sys.stderr.write("Invalid port number: "+a+"\n")
sys.exit(2)
if o == "--user":
user = a
if o == "--pass":
password = a
if o in ("-v", "--verbose"):
verbose = 1
if o in ("-r", "--readermode"):
readermode = 1
#post message
if verbose:
print "Connecting to Server..."
try:
s = nntplib.NNTP(server, port, user, password, readermode)
except Exception, e: # it can throw a class exception...
sys.stderr.write("Can't connect to server: "+server+"\n")
sys.stderr.write(str(e)+"\n")
sys.exit(2)
except: # ... or a string exception
sys.stderr.write("Can't connect to server: "+server+"\n")
sys.stderr.write(sys.exc_info()[1]+"\n")
sys.exit(2)
if verbose:
print "Posting article..."
try:
s.post(file)
except Exception, e: # it can throw a class exception...
sys.stderr.write("Can't post the given input.\n")
sys.stderr.write(str(e)+"\n")
sys.exit(2)
except: # ... or a string exception
sys.stderr.write("Can't post the given input.\n")
sys.stderr.write(sys.exc_info()[1]+"\n")
sys.exit(2)
s.quit()
def usage():
print "postnews 0.5.3 - (C) 2001 by Michael Waschbuesch <MichaelWaschbuesch@web.de>"
print ""
print "Usage: postnews [OPTIONS] SERVER"
print "Post a usenet article (including headers) from stdin onto SERVER."
print "Article must at least contain the headers 'From:', 'Newsgroups:' and 'Subject:',"
print "a newline and a body."
print ""
print "Options: -h, --help display this text"
print " -v, --verbose be verbose"
print " -f, --file=FILE read file instead of stdin"
print " -p, --port=PORT port number"
print " --user=NAME user name"
print " --pass=PASSWD password"
print " -r, --readermode send MODE READER before authentication"
if __name__ == "__main__":
main()
|