Article View: alt.free.newsservers
Article #164187Re: SOLVED: What is a quick Linux bash test of a free public newsserver on VPN?
From: VPN user
Date: Wed, 30 Mar 2016 13:56
Date: Wed, 30 Mar 2016 13:56
108 lines
4085 bytes
4085 bytes
VPN user wrote in message ndf7na$29b$10@news.mixmin.net
>> Here is the except Bash script.
BTW, for some reason, the "logic" fails but I can't for the life of
me see why it failed.
Here is a run I just made using the script below, which took less than
30 seconds between the first run and the fourth.
Do you know *why* the script fails the first 3 times, yet doing it
manually works the 4th time?
In all four cases, the script runs the *exact* same command!
Run 1:
$ vpnusenet.sh
Trying 46.165.242.75...
Connected to nntp.aioe.org.
Escape character is '^]'.
Connection closed by foreign host.
Posting is not ok because the exit return status was false = 1
Run 2:
$ vpnusenet.sh nntp.aioe.org
Trying 46.165.242.75...
Connected to nntp.aioe.org.
Escape character is '^]'.
Connection closed by foreign host.
Posting is not ok because the exit return status was false = 1
Run 3:
$ vpnusenet.sh nntp.aioe.org 119
Trying 46.165.242.75...
Connected to nntp.aioe.org.
Escape character is '^]'.
Connection closed by foreign host.
Posting is not ok because the exit return status was false = 1
Run 4:
$ telnet nntp.aioe.org 119
Trying 46.165.242.75...
Connected to nntp.aioe.org.
Escape character is '^]'.
200 nntp.aioe.org InterNetNews NNRP server INN 2.5.4 ready (posting ok)
quit
205 Bye!
Connection closed by foreign host.
Here is the bash script for your tests:
#!/bin/bash
# vpnusenet.sh will test whether nntp posting is ok given the current vpn server
# USE: $ vpnusenet.sh (will use the default newssserver nntp.aioe.org & default port 119)
# USE: $ vpnusenet.sh freenews.netfront.net (will use the given newsserver & default to the port 119)
# USE: $ vpnusenet.sh news.mozilla.org 119 (will use the given newsserver & the stated port)
# Free error checking:
set -u
# Output storage:
_outFile=/tmp/nntp.out
# Default newsserver and port:
_nntpServer=nntp.aioe.org
_nntpPort=119
# If openvpn is not currently running, then exit.
openvpnPID=$(pgrep openvpn)
if [ $? -ne 0 ]; then
echo "Oops: Openvpn is not running."
exit 1
fi
# If the total number of arguments is 1, then use that nntp server & the default nntp port.
# e.g., news.mixmin.net:119, freenews.netfront.net:119, news.mozilla.org:119, etc.
if [ $# -eq 1 ]; then
_nntpServer=$1
fi
# If the total number of arguments is 2, then use that nntp server & that nntp port.
# e.g., nntp.aioe.org:443, nntp.aioe.org:563, news.mixmin.net:563, etc.
if [ $# -eq 2 ]; then
_nntpServer=$1
_nntpPort=$2
fi
# If the total number of arguments is greater than 2, then consider that an error.
if [ $# -gt 2 ]; then
echo "Oops: Too many arguments; maximum of 2"
exit 1
fi
# Attempt to connect to the given nntp server:
(
sleep 1
echo "quit";
) | telnet $_nntpServer $_nntpPort | tee $_outFile
# Test if the nntp server allows posting from the current openvpn IP address:
grep "posting ok" $_outFile
if [ "$?" = "0" ]; then
echo "Posting is ok because the exit return status was true = 0" # output on standard out
else
echo "Posting is not ok because the exit return status was false = 1" 1>&2 # output on standard error
fi
exit 0
## End ##
Technical Details
Message-ID:
<ndglv0$oiv$3@news.mixmin.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mailReferences:
<nda1rf$65o$1@news.mixmin.net> <ndboei$tur$2@news.mixmin.net> <ndf7j1$29b$9@news.mixmin.net> <ndf7na$29b$10@news.mixmin.net>Show Full Headers
Complete Article Headers
Message-ID: <ndglv0$oiv$3@news.mixmin.net> Subject: Re: SOLVED: What is a quick Linux bash test of a free public newsserver on VPN? Date: Wed, 30 Mar 2016 13:56:48 +0000 From: VPN user <vpnuser@example.com> References: <nda1rf$65o$1@news.mixmin.net> <ndboei$tur$2@news.mixmin.net> <ndf7j1$29b$9@news.mixmin.net> <ndf7na$29b$10@news.mixmin.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!apf1.newsdeef.eu!not-for-mail Newsgroups: alt.free.newsservers Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 30 Mar 2016 13:56:48 -0000 (UTC) X-Received-Bytes: 4165 Organization: Mixmin Content-Type: text/plain; charset=UTF-8