On Fri, Jul 27, 2001 at 12:29:09AM -0400, Joel Hammer wrote:
> I don't know how to make mutt distinguish between pdf and word (doc)
> documents. They both show up as octet stream. So, I am trying to put a test
> command into my mailcap file to test which type of file is attached, doc or
> pdf. I am not having much luck, so I think I need some help.
This is a common problem. One solution has been to write a script that
is invoked to view any application/octet-stream attachment and let that
script choose the appropriate viewer based on the file name extension of
the attachment. For an example, see
http://www.spocom.com/users/gjohnson/mutt/#octet
Another solution has been to modify mutt itself to scan the mime.types
file for the application type corresponding to the file name extension,
then scan the mailcap file again to find the viewer for this application
type. I don't have a reference handy for this patch, but it's been
discussed in the mutt-dev list.
> Here is my mailcap line for pdf:
>
> application/octet-stream;/opt/Acrobat3/bin/acroread %s;
>test=/usr/local/bin/mutt-testpdf %s
>
> Here is my script to test for the pdf file:
>
> echo "This is 0" $0 > /home/jlh/junk
> echo "This is 1" $1 >> /home/jlh/junk
> echo "This is all" $* >> /home/jlh/junk
> i=`echo $0 | sed -n "/\.pdf$/p"`
> [ -n "$i" ] && echo 0 || echo 1
>
> Now, I have found many difficulties.
> First, %s never gets carried over into my script, which I test by looking at that
>junk file.
I've noticed that, too. I don't know why it seems to work every place
except the test field.
> If I put a constant string in place of %s, then it shouws up as $1.
> $0 shows the name of the command. I thought that sh -c makes the first argument $0,
>not $1.
Nope. $0 is always the name by which the command was invoked and $1 is
always the first argument.
> Finally, if I make my test script just echo a 1, acroread is still
> invoked.
'echo 1' will put an ASCII 1 on your script's stdout. You want to set
the return value of the script, which is done with the 'exit' command,
e.g., 'exit 0' for success and 'exit 1' for failure. Since the exit
status of a script is the exit status of the last command, you could
simply end your script with
test -n "$i"
Of course, your script isn't going to work since you can't pass it the
file name, but at least you've learned a little about shell scripts.
> So, I am really confused.
> Any insight appreciated.
HTH,
Gary
--
Gary Johnson | Agilent Technologies
[EMAIL PROTECTED] | Spokane, Washington, USA
http://www.spocom.com/users/gjohnson/mutt/ |