🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #203185

Re: How to access a post by Message-ID

#203185
From: Stefano Sabatini
Date: Sun, 05 Aug 2007 09:46
117 lines
4415 bytes
On 2007-08-05, »Q« <boxcars@gmx.net> wrote:
> In <news:slrnfb8lfe.usu.stefano.sabatini@santefisi.caos.org>,
> Stefano Sabatini <stefano.sabatini@caos.org> wrote:
>
>>permits to do it, but I would like to do it automatically, e.g. with a
>>script which takes the message id and assemblate an
>>address corresponding to the Google Gorups/other archive page.
>
> I just had to write a script to generate a list of links from a text
> file containing MID headers, so I'll use your post as an excuse to post
> it.
>
> This doesn't help you directly, but I guess parts of it could be used
> in a script that slrn could pipe articles or just headers to.  The grep
> and sed parts are the important bits.
>
> It's intended to work on .mbox or other files with multiple MID
> headers, but it would work on single posts ok.  Output is a list of
> links.  Piping output to xargs firefox or xargs konqueror opens the
> links in tabs (depending on the browser's settings, I guess).  Opera
> needs some extra option I can't recall, but opera --help would turn it
> up.
[...]

Thanks »Q«!

I already had my script, which I'm going to publish for the archive.
Anyway, with SLRN should be possible to parse the message using S-lang
facilities, which is more efficient and gives more control (but I'm
still figuring out how to do).

Enjoy the getopt parsing in bash!

#!/bin/bash

# strip leading base path 
$my_name=${0##*/}

browse_command=~/bin/web-browse

E_BADARGS=65

usage() {
    cat <<EOT
Usage: $my_name -h|--help|--usage
       $my_name <options> [<message-filename>]

Grep the file for the message-id, assemblate a corresponding
google groups url, echo such url on stdout and eventually launch a 
browser on it.
The browser command is "$browse_command".
If no file in input is given then filter stdin.

Options:
-h|--help|--usage          Print this help and exit
-b|--browse                Launch the browser on the found url
EOT
}

browse=off

# reset the arguments strings using the parsing facility provided by getopt
args=$(getopt -lhelp -lusage -lbrowse -o bh -- $@)
# integer comparison: -eq, -ne, -lt, -gt
if [ $? -ne 0 ]; then
	echo "$my_name: parsing error" 1>&2
	usage 1>&2
	exit $E_BADARGS
fi

eval set -- $args

# command line arguments parsing
# continue when there are arguments to parse
while true; do
    case "$1" in
	    -h|--help|--usage) 
	  	  usage 
		  exit 0
		  ;;
		-b|--browse)
		  browse=on
		  shift
		  ;;
	  # getopt puts a "--" at the end of the parsed options
  	    --)
	  	  shift
		  break
		  ;; 
	esac
done

message_id=$(grep -i "^Message-id:" $1 | sed -e 's/.*<\(.*\)>/\1/')
if [ -z "$message_id" ]; then
    echo "$my_name: no message-id found in input or no input." 1>&2
	exit 1
fi

# freenix.org mode
#url_base='http://howardk.freenix.org/msgid.cgi?STYPE=msgid&MSGI='
#mangled_message_id=$(echo "%3C${message_id}%3E" | \
#sed -e 's/%\([[:alpha:]]\)/%25\1/g' | \
#sed -e 's/@/%40/g')
#
#url=${url_base}${mangled_message_id}

url="http://groups.google.com/groups?selm=${message_id}&dmode=source"
echo $url

if [ "$browse" = "on" ]; then
	$browse_command $url
fi

Cheers.
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
Technical Details
Message-ID: <slrnfbb73c.l9g.stefano.sabatini@santefisi.caos.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!storethat.news.telefonica.de!telefonica.de!news-fra1.dfn.de!feeder.erje.net!aioe.org!not-for-mail
References: <slrnfb8lfe.usu.stefano.sabatini@santefisi.caos.org> <omnfo4-nbq.ln1@goldry.remarqs.net>

Show Full Headers
Complete Article Headers
Message-ID: <slrnfbb73c.l9g.stefano.sabatini@santefisi.caos.org>
Subject: Re: How to access a post by Message-ID
Date: Sun, 05 Aug 2007 09:46:20 +0000
From: Stefano Sabatini <stefano.sabatini@caos.org>
References: <slrnfb8lfe.usu.stefano.sabatini@santefisi.caos.org> <omnfo4-nbq.ln1@goldry.remarqs.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!storethat.news.telefonica.de!telefonica.de!news-fra1.dfn.de!feeder.erje.net!aioe.org!not-for-mail
Newsgroups: news.software.readers
Organization: Debian GNU/Linux site
Lines: 117
Reply-To: stefano.sabatini@santefisi.caos.org.invalid
NNTP-Posting-Host: i9cRMEi8124mRCQkAMx6qA.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@aioe.org
User-Agent: slrn/0.9.8.1pl1 (Debian)