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
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)