> I also don't have the URL handy, but it should be available in the
> list archives at least. Possibly also on the Links page at
> www.mutt.org.
I have been using it for a long time and made some small extensions.
It's attached to this mail. No idea where the original is, sorry.
Have fun,
Andy.
--
E-Mail: [EMAIL PROTECTED] URL: http://andy.spiegl.de
PGP/GPG: see headers
o _ _ _
--------- __o __o /\_ _ \\o (_)\__/o (_)
------- _`\<,_ _`\<,_ _>(_) (_)/<_ \_| \ _|/' \/
------ (_)/ (_) (_)/ (_) (_) (_) (_) (_)' _\o_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Those who do not understand Unix are condemned to reinvent it, poorly.
-- Henry Spencer
#!/bin/sh
#
# mutt.octet.filter - Octet filter for use with the mutt autoview facility
# Copyright (C) 1997,1998,1999 David A Pearson
#
# Changes by Andy Spiegl <[EMAIL PROTECTED]>, 1999, 2000
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the license, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# This script file is a pretty brain-dead, last resort, "works for me"
# utility that will attempt to make sense of any octet-stream data
# that is received as part of an email and act as a filter for use
# with mutt's auto_view ability.
#
# Here is how I use it. In my ~/.mutt_mailcap (use your filename of
# choice) I have the following entry:
#
# application/octet-stream; mutt.octet.filter %s | vcat -s; copiousoutput
#
# 'vcat' is a silly little utility that strips any non-printing
# characters, use your non-printing filter of choice. You don't need
# that filter there, mutt.octet.filter attempts to not show binary
# data, but belt and braces can be a good idea now and again.
#
# All you then need to do is add a line like:
#
# auto_view application/octet-stream
#
# to your ~/.muttrc (use your filename of choice).
#
# In it's current state the script isn't perfect, it's your typical
# "works for me" type of script and is offered in the hope that it
# maybe handy and that you can do something with it.
#
# All comments/flames/feedback can be directed to:
#
# [EMAIL PROTECTED]
#
# $Log: mutt.octet.filter,v $
# Revision 1.2 1999/01/27 17:35:25 davep
# Added handling for .bz2 files (thanks to Lars Hecking for that).
# Added handling of MSWord documents (requires catdoc).
#
# Revision 1.1 1998/10/14 16:00:25 davep
# Initial revision
#
# many changes by ASp
# among them: -t switch
# if -t is given as parameter, all output is converted to text
# if not, images etc. are displayed using X
ShowTAR()
{
tar tvvf "$1" 2> /dev/null
}
ShowTGZ()
{
tar tzvvf "$1" 2> /dev/null
}
ShowGZIP()
{
gzip -dc "$1" 2> /dev/null
}
ShowBZIP()
{
bzip2 -dc "$1" 2> /dev/null
}
ShowZIP()
{
unzip -l "$1" 2> /dev/null
}
ShowARJ()
{
unarj l "$1" 2> /dev/null
}
ShowEXE()
{
echo $(basename "$1"): DOS/Windows executable
}
ShowOBJ()
{
echo $(basename "$1"): DOS/Windows object file
}
ShowLIB()
{
echo $(basename "$1"): MS-DOS program library
}
ShowNG()
{
echo $(basename "$1"): Norton Guide Database
}
ShowVCard()
{
cat "$1" | mutt.vcard.filter
}
ShowTIF()
{
if [ "$textoutput" == "true" ]; then
tiffinfo "$1"
else
xv "$1"
fi
}
ShowIMG()
{
if [ "$textoutput" == "true" ]; then
(djpeg -pnm $1 | pnmscale -xysize 80 92 | ppmtopgm | pgmtopbm | pbmtoascii -1x2
) 2>&1
else
xv "$1"
fi
}
ShowPNG()
{
if [ "$textoutput" == "true" ]; then
echo $1 is a PNG image. Sorry, cannot convert to ASCII.
else
xv "$1"
fi
}
ShowPS()
{
if [ "$textoutput" == "true" ]; then
# echo $1 is a Postscript document.
ps2ascii $1
else
acroread "$1"
fi
}
ShowPDF()
{
if [ "$textoutput" == "true" ]; then
# echo $1 is a PDF document.
pdf2ascii $1
else
acroread "$1"
fi
}
ShowMSWord()
{
# catdoc "$1"
# ASp: first, let's see if this is really MicroSoft nonsense...
ldat "$1" | grep -is microsoft > /dev/null
if [ $? -eq 0 ]; then
echo "`basename "$1"` is a Microsoft document:"
ldat "$1"
lhalw -F "$1"
else
echo "`basename "$1"` unprintable data:"
strings --bytes=5 $1
fi
}
Showdata()
{
# let's see if this is MicroSoft nonsense..."
ldat "$1" | grep -is microsoft > /dev/null
if [ $? -eq 0 ]; then
echo "`basename "$1"` is a Microsoft document:"
ldat "$1"
lhalw -F "$1"
else
echo "`basename "$1"` unprintable data:"
strings --bytes=5 $1
fi
}
DisplayFileType()
{
echo "[-- $(basename $0) file type: \"$1\" --]"
echo
}
ShowFileType()
{
FILE_TYPE=$(echo $(file "$1" 2> /dev/null) | cut -d' ' -f 2-)
DisplayFileType "$FILE_TYPE"
}
# ASp
ShowUnknown()
{
echo "`basename "$1"` is of unknown file type"
echo "Contains these strings:"
strings --bytes=5 $1
}
ShowMISC()
{
FILE_TYPE=$(file -z "$1" 2> /dev/null)
if [ $? -gt 0 ]
then
FILE_TYPE=$(file "$1" 2> /dev/null)
fi
FILE_TYPE=$(echo "$FILE_TYPE" | cut -d' ' -f 2-)
DisplayFileType "$FILE_TYPE"
case "$FILE_TYPE" in
*tar*archive*gzip* ) ShowTGZ "$1";;
*tar*archive* ) ShowTAR "$1";;
*gzip* ) ShowGZIP "$1";;
*ARJ*archive*data* ) ShowARJ "$1.";; # "." gets round bug in unarj.
*zip*archive*file* ) ShowZIP "$1";;
*TIFF*image*data* ) ShowTIF "$1";;
*JPEG*image*data* ) ShowIMG "$1";;
*GIF*image*data* ) ShowIMG "$1";;
*PNG*image*data* ) ShowPNG "$1";;
*PostScript* ) ShowPS "$1";;
*postscript* ) ShowPS "$1";;
*PDF*document* ) ShowPDF "$1";;
*DOS*executable* ) ShowEXE "$1";;
*ascii*text* ) cat "$1";;
*c*program*text* ) cat "$1";;
*8086*reloc*Micro* ) ShowOBJ "$1";;
*MS-DOS*prog*lib* ) ShowLIB "$1";;
data ) Showdata "$1";;
# * ) cat "$1";;
* ) ShowUnknown "$1";;
esac
}
if [ "$1" = "" ]
then
echo "syntax: $(basename [-t] '$0') file"
else
if [ "$1" = "-t" ]
then
textoutput=true
shift
fi
case "$1" in
*.tar ) ShowFileType "$1"; ShowTAR "$1";;
*.tgz ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.gz ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.Z ) ShowFileType "$1"; ShowTGZ "$1";;
*.tar.z ) ShowFileType "$1"; ShowTGZ "$1";;
*.Z ) ShowFileType "$1"; ShowGZIP "$1";;
*.z ) ShowFileType "$1"; ShowGZIP "$1";;
*.gz ) ShowFileType "$1"; ShowGZIP "$1";;
*.bz2 ) ShowFileType "$1"; ShowBZIP "$1";;
*.zip ) ShowFileType "$1"; ShowZIP "$1";;
*.ZIP ) ShowFileType "$1"; ShowZIP "$1";;
*.arj ) ShowFileType "$1"; ShowARJ "$1";;
*.ARJ ) ShowFileType "$1"; ShowARJ "$1";;
*.log ) ShowFileType "$1"; cat "$1";;
*.LOG ) ShowFileType "$1"; cat "$1";;
*.obj ) ShowFileType "$1"; ShowOBJ "$1";;
*.OBJ ) ShowFileType "$1"; ShowOBJ "$1";;
*.lib ) ShowFileType "$1"; ShowLIB "$1";;
*.LIB ) ShowFileType "$1"; ShowLIB "$1";;
*.NG ) ShowFileType "$1"; ShowNG "$1";;
*.ng ) ShowFileType "$1"; ShowNG "$1";;
*.vcf ) ShowFileType "$1"; ShowVCard "$1";;
*.tif ) ShowFileType "$1"; ShowTIF "$1";;
*.jpg ) ShowFileType "$1"; ShowIMG "$1";;
*.doc ) ShowFileType "$1"; ShowMSWord "$1";;
* ) ShowMISC "$1";;
esac
fi