#!/bin/ksh # # $Revision: 1.5 $ $Date: 2010/01/05 19:47:19 $ # $Source: /home/vogelke/bin/RCS/w3m,v $ # $Host: myhost.com $ # $UUID: 5b69c9d8-fedf-321c-89b6-b236090aa02f $ # # Fetch files via wget, w3m. PATH=/usr/local/bin:$PATH export PATH die () { echo "$*" >& 2 exit 1 } # Sanity checks. case "$1" in "") die "usage: $0 url" ;; *local*) opt="--proxy=off $1" ;; http*) opt="$1" ;; ftp*) opt="$1" ;; esac # Fetch the URL back to a temporary file using wget. # mktemp filenames MUST end with X's, so change the tempfile # afterwards; that's safe because if file xyz doesn't exist, # xyz.htm and 00xyz don't exist either (on my system at least). url="$1" tfile=$(mktemp w3mXXXXXX) test -f $tfile || die "mktemp failed" wget -F -O $tfile.htm $opt test -s $tfile.htm || die "wget failed" # Render the temporary file using w3m: better support for tables. case "$WCOLS" in "") cols=75 ;; *) cols="$WCOLS" ;; esac ## IF w3m works: render="/usr/local/bin/w3m -no-graph -dump -T text/html -cols $cols" ## IF lynx works: #render="/opt/sfw/bin/lynx -dump -width $cols" out="00$tfile" (echo $url && $render $tfile.htm) > $out test -s "$out" && $EDITOR $out && echo $out rm -f $tfile $tfile.htm exit 0