Groups | Search | Server Info | Login | Register


Groups > comp.infosystems.gopher > #234

Re: a gopher use case

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed9.news.xs4all.nl!85.12.16.69.MISMATCH!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx06.fr7.POSTED!not-for-mail
From RS Wood <rsw@therandymon.com>
Newsgroups comp.infosystems.gopher
Subject Re: a gopher use case
References <j6uuse-sa3.ln1@raspberry.therandymon.com> <slrn3v9kpgcokh.qam.f6k@faeroes.freeshell.org>
Message-ID <87h8mvdxro.fsf@therandymon.com> (permalink)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock sha1:3ZL/XaOsJ2iGCrvX6/XOyvn+/qE=
MIME-Version 1.0
Content-Type text/plain
Lines 83
X-Complaints-To abuse@blocknews.net
NNTP-Posting-Date Sat, 26 May 2018 02:58:03 UTC
Organization blocknews - www.blocknews.net
Date Fri, 25 May 2018 21:13:47 -0400
X-Received-Bytes 3390
X-Received-Body-CRC 1101773984
Xref csiph.com comp.infosystems.gopher:234

Show key headers only | View raw


FGK <f6k@sdf.org> writes:
> On 2018-05-17, RS Wood <rsw@therandymon.com> wrote:
>> and one ridiculously short bash script
>
> I'm not very good at scripting. I'm just imagining you're using lynx
> -dump and echo $DATE at some point, but for the categories and, most
> of all, to render it properly in .txt (i mean just the article, not
> the whole webpage with menu, etc.) I'm quite lost.
>
> Would you mind share your script with us please so I can have a better
> insight of what to do? Thank you very much.
>
> ~f6k


Just realized I replied, rather than following up to the Newsgroup.  For
anyone else interested, here it is:

First, you have to create the gopher directories in advance, ie set up your
hierarchy.  I just mkdir a couple of directories under /var/gopherhole/. 
The trick to cleaning up the file is passing it to an editor.  I use JOE (in
this case, the jstar variant), because it can edit text passed to it via
stdin.  (emacs, vim etc. don't like it and I haven't figured out why).  So
basically:

1. take whatever text got passed to the script and dump it in a temporary
file under /tmp
2. Ask for a filename to give it
3. Ask which directory to save it under
4. Make a file name, consisting of date and the name the user chose
5. Save it using cat

Save the following in ~/bin as gopherize.sh.  Chmod it u+x.  Then, from any
other app you can pipe text to it.  I'm now using it for RSS feeds but also
the occasional email, web pages I'm reading with lynx, etc.  Any time you
need a new category you need to manually create it and then edit the script
so the new category shows up in your case statement. 

#! /bin/bash
# Take some bit of text, save it as a text file so that gopher can serve
# it up from an organized directory.

TEMPTEXT='/tmp/temptext'

while read line;
do
	echo "$line" >> $TEMPTEXT
done

echo "Name of this future file (eg solar_prices_drop)."
echo "Use one word; date will be prepended so we get"
echo "something like 2018-05-08-solar_prices_drop."
read NUGGETNAME < /dev/tty

echo ""
echo "In which gopher hole to save it?"
echo "u] utilities"
echo "w] wind"
echo "b] battery storage"
echo "s] solar"

read WHICHHOLE < /dev/tty

case $WHICHHOLE in
	u) GOPHERHOLE='/var/gopherhole/utilities/' ;;
	w) GOPHERHOLE='/var/gopherhole/wind/' ;;
	b) GOPHERHOLE='/var/gopherhole/batteries/' ;;
	s) GOPHERHOLE='/var/gopherhole/solar/' ;;
	*) GOPHERHOLE='/var/gopherhole/' 
esac


NUGDATE=`date +%Y-%m-%d-%T`
echo "Storing that gopher nugget at $GOPHERHOLE$NUGDATE-$NUGGETNAME"
echo ""
echo "Press the AnyFuckingKey to continue."
read ANYFUCKINGKEY < /dev/tty

jstar $TEMPTEXT

cat $TEMPTEXT > $GOPHERHOLE$NUGDATE-$NUGGETNAME

Back to comp.infosystems.gopher | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

a gopher use case RS Wood <rsw@therandymon.com> - 2018-05-17 00:15 +0000
  Re: a gopher use case FGK <f6k@sdf.org> - 2018-05-24 06:58 +0000
    Re: a gopher use case RS Wood <rsw@therandymon.com> - 2018-05-25 21:13 -0400
      Re: a gopher use case FGK <f6k@sdf.org> - 2018-05-26 13:13 -0500
        Re: a gopher use case RS Wood <rsw@therandymon.com> - 2018-05-26 21:58 -0400

csiph-web