blob: d151504dc093ee039f108f52b9d893a6c4ba7dcf (
plain) (
blame)
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
|
#!/usr/bin/ruby
# mblow - post an article via NNTP
require 'socket'
require 'optparse'
params = ARGV.getopts("s:")
port = 119
if params["s"] =~ /(.*):(.*)/
params["s"] = $1
port = Integer($2)
end
SERVER = params["s"] || ENV["NNTPSERVER"] || "news"
nntp = TCPSocket.new SERVER, port
msg = nntp.gets
abort msg unless msg =~ /^200 /
nntp.write "POST\r\n"
msg = nntp.gets
abort msg unless msg =~ /^340 /
while line = gets
line.chomp!
line.sub!(/\A\./, '..')
nntp.write(line + "\r\n")
end
nntp.write(".\r\n")
msg = nntp.gets
abort msg unless msg =~ /^240 /
|