On Tue, Nov 07, 2000 at 02:07:42PM -0100, Dirk Ruediger wrote:
> Hi all!
> 
> On Tue, 07 Nov 2000, Jan Houtsma wrote:
> 
> > On Tue, Nov 07, 2000 at 12:13:23AM +0100, Martin Schweizer wrote:
> > > Hello
> > > 
> > > How can I see the above files with mutt(1.0.1i) on a FreeBSD-Box (4.0) without
> > > StarOffice?
> > 
> > If you don't mind using X-programs, but like me only dont want to start 
> > this beast StartOffice you can try AbiWord for .doc files and
> > (under gnome) gnumeric for xls files. Works great for me.
> For me too (despite of missing table support in Abiword).
> 
> > For text only i use wvHtml for .doc files. I don't have anything for xls 
> > that can display on text only terminals.
> 
> XLS:
> http://www.xlhtml.org/
> 
> Office filters:
> http://arturo.directmail.org/filtersweb/
> 
> Word processors:
> http://www.w3.org/Tools/Word_proc_filters.html
> 
> Converters in general:
> http://directory.google.com/Top/Computers/Software/Internet/Authoring/Converters/
> 
> Ciao for now, Dirk

This script can be used for viewing a bunch of well known file types.
The script looks for an X environment and launches either a graphical
program or an ascii oriented program.
It looks at the extension and its magic number (in that order) to 
determine the file type. Its by far complete but can be extended as
needed.

I am using this script almost everywhere for viewing files so also in mutt.
The script uses /bin/zsh, but /bin/bash should work as well.

Usage: pitview [-dtH] <filename> [ filename filename ... ]
   or: pitview [-dtH] <url>

      -d = dump (implies -t)
      -t = text mode
      -H = you'r looking at it :-)

for example 'pitview memo.doc'
            'pitview students.xls'
            'pitview www.mutt.org'
            'pitview RobbieWilliams_KylieMinogue-Kids.mp3'
             ...

e.g. .urlview: COMMAND pitview %s
e.g.  mailcap: text/html; pitview %s; test=RunningX
               text/html; pitview %s; nametemplate=%s.html
               application/msword; pitview %s; test=RunningX
               application/msword; pitview -d %s; copiousoutput
               application/msexcel; pitview -d %s; copiousoutput
               ...

Just wanted to share with the group as someone might find it useful (or not).
jan
-- 
  pgp: http:://www.houtsma.net/~jan/openpgp.asc
               ___     ___     ___
              /  /    /  /    /  /  Jan H. Houtsma
             /  /    /  /    /  /   Comeniushof 92
            /  /____/  /____/  /    1216 HH Hilversum
     ___   /  _____   _____   /     Netherlands
    /  /  /  /    /  /    /  /      
   /  /__/  /    /  /    /  /       http://www.houtsma.net
  /________/    /__/    /__/        [EMAIL PROTECTED]
#!/bin/zsh
#
SCRIPTNAME=${0##*/}

typeset Help="# View files of different types inside or outside X
#
# Usage: $SCRIPTNAME [-dtH] <filename> [ filename filename ... ]
#    or: $SCRIPTNAME [-dtH] <url>
#
#       -d = dump (implies -t)
#       -t = text mode
#       -H = you'r looking at it :-)
#
# Author: Jan Houtsma
#
# This script can be used for viewing a bunch of well known file types.
# The script looks for an X environment and launches either a graphical
# program or an ascii oriented program.
# It looks at the extension and its magic number (in that order) to 
# determine the file type."
#
# Note that this works under the Linux/Gnome/Enlightenment environment.
# Some programs mentioned below might need to be additionally installed.
#
# Needed programs to view various types files:
#       RunningX        to determine if X windows can be opened
#       w3m             html                Ascii
#       netscape        html                X11
#       AbiWord         M$ word             X11
#       wvHtml          M$ word             Ascii
#       gnumeric        M$ xls              X11
#       xlHtml          M$ xls              Ascii
#       gv              postscript          X11
#       acroread        pdf                 X11
#       ee              gif, jpeg, tiff     X11
#       rpm             rpm                 Ascii
#       esdplay         wav, au             Ascii
#       xmms            mp3                 X11
#       mpg123          mp3                 Ascii
#

TMP=$HOME/tmp
h=$TMP/$SCRIPTNAME.$$.html
e=$TMP/$SCRIPTNAME.error

function mylynx
{
    if ((dump))
    then
        #lynx -dump $1
        w3m -dump -T text/html $1
    else
        w3m -T text/html $1
    fi
}

function view_html
{
    if [ -f $1 ] 
    then
        # construct a valid local url (file://...)
        d=`dirname $1`
        f=${1##*/}
        cd $d
        p=`pwd`
        cd - >/dev/null
        f="file://$p/$f"
    else
        # if not a local filename it must be an url...
        f=$1
    fi
    if ((!text)) && RunningX 2>/dev/null
    then
        if [ -L $HOME/.netscape/lock ]
        then
            netscape -remote "openURL($f)"
        else
            netscape $f
        fi
    else
        mylynx $f
    fi
}

function view_mp3
{
    if ((!text)) && RunningX 2>/dev/null
    then
        xmms $1
    else
        mpg123 $1
    fi
}

function view_doc
{
    if ((!text)) && RunningX 2>/dev/null
    then
        AbiWord $1 2>$e
    else
        wvHtml $1 $h 2>$e
        mylynx $h
    fi
}

function view_xls
{
    if ((!text)) && RunningX 2>/dev/null
    then
        gnumeric $1 >$e 2>&1
    else
        xlHtml -fw -asc ict.xls >$h 2>$e
        mylynx $h
    fi
}

###################
# option processing
###################
OPTS="dtH"
integer dump=0
integer text=0
while getopts :${OPTS} c
do      case $c in
        H)      echo "$Help"; exit 0 ;;
        d)      dump=1
                text=1;;
        t)      text=1;;
        :)      print -u2 "$SCRIPTNAME: $OPTARG requires a value"
                exit 2 ;;
        \?)     print -u2 "$SCRIPTNAME: unknown option $OPTARG"
                exit 2 ;;
        esac
done
shift OPTIND-1

trap '
    rm -f $h
' EXIT HUP INT QUIT TERM KILL ILL TRAP

if [ ! -d $TMP ]
then
    mkdir $TMP
fi

for i in $*
do
    if [ -f $i ]
    then
        tp=`file -b $i`
    else
        tp="HTML document text" # typed in url
    fi

    case $i in
    *.doc|*.DOC) 
        view_doc $i ;;
    *.xls|*.XLS)  
        view_xls $i ;;
    *.html|*.HTML|*.htm|*.HTM)
        view_html $i ;;
    *.ps|*.PS)
        gv $i ;;
    *.pdf|*.PDF)
        acroread $i ;;
    *.gif|*.GIF)
        ee $i ;;
    *.jpg|*.JPG)
        ee $i ;;
    *.tiff|*.TIFF)
        ee $i ;;
    *.bmp|*.BMP)
        ee $i ;;
    *.rpm|*.RPM)
        rpm -qilp $i ;;
    *.wav|*.WAV)
        esdplay $i ;;
    *.au|*.AU)
        esdplay $i ;;
    *.mp3|*.MP3)
        view_mp3 $i ;;
    *)
        case $tp in
        "ASCII text"*)
            cat $i ;;
        "Microsoft Office Document"*)
            case $i in
            *.doc)  
                view_doc $i ;;
            *.xls)  
                view_xls $i ;;
            *)  
                print -u2 "$SCRIPTNAME: unrecognized Microsoft Office Document: $i"
                exit 2 ;;
            esac
            ;;
        "HTML document text"*)
            view_html $i ;;
        "PostScript document text"*)
            gv $i ;;
        "PDF document"*)
            acroread $i ;;
        "GIF image data"*)
            ee $i ;;
        "JPEG image data"*)
            ee $i ;;
        "TIFF image data"*)
            ee $i ;;
        "PC bitmap data"*)
            ee $i ;;
        "RPM"*)
            rpm -qilp $i ;;
        "RIFF (little-endian) data, WAVE audio"*)
            esdplay $i ;;
        "Sun/NeXT audio data"*)
            esdplay $i ;;
        "MP3"*)
            view_mp3 $i ;;
        *)
            print -u2 "$SCRIPTNAME: unrecognized document type: $i"
            exit 2
        esac
        ;;
    esac
done

Reply via email to