On 2007-09-18, "Wilkinson, Alex" <[EMAIL PROTECTED]> wrote:
>     0n Tue, Sep 18, 2007 at 12:43:42AM -0700, Gary Johnson wrote: 
> 
>     >I need the "mutt_rem_bgrun" command because I run mutt on a Solaris 
>     >machine and run viewers for MS attachments remotely on the Linux 
>     >box.  In your case, this might work:
> 
> Where does one find details on "mutt_rem_bgrun" ?

I normally publish such scripts on my web page, 
http://www.spocom.com/users/gjohnson/mutt, but this one seemed of 
little general interest, so I didn't.

My desktop runs Linux, but I use Solaris machines for most of my 
work.  My home directory is accessible from all of them.
I read my mail on Solaris, but Linux has more tools for viewing MS 
attachments, so I use this script to save the attachment file to a 
temporary directory under $HOME and then run the viewer on Linux.

I leveraged most of the script from another I wrote, and which is on 
my web page, mutt_bgrun.  That runs a viewer on the local machine 
but in the background so that the user can continue to use mutt.

The script is small enough that I'll just attach it.

The name of the Linux machine is hard-coded, so you'll have to 
change that if you want to use it yourself.

Regards,
Gary
#!/bin/sh
# @(#) mutt_rem_bgrun $Revision: 1.1 $

#   mutt_rem_bgrun - run an attachment viewer on a remote machine in the 
background
#   Copyright (C) 1999-2007 Gary A. Johnson
#
#   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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

# SYNOPSIS
#       mutt_rem_bgrun viewer [viewer options] file
#
# DESCRIPTION

#
# EXAMPLE
#       To use gnumeric to view Excel attachments from mutt, add the
#       following line to mutt's mailcap file.
#
#       application/vnd.ms-excel;       mutt_rem_bgrun gnumeric %s
#
# AUTHOR
#       Gary A. Johnson
#       <[EMAIL PROTECTED]>

prog=${0##*/}

# Check the arguments first.

if [ "$#" -lt "2" ]
then
    echo "usage: $prog viewer [viewer options] file" >&2
    exit 1
fi

# Separate the arguments.  Assume the first is the viewer, the last is
# the file, and all in between are options to the viewer.

viewer="$1"
shift

while [ "$#" -gt "1" ]
do
    options="$options $1"
    shift
done

file=$1

# Create a temporary directory for our copy of the temporary file.
#
# This is more secure than creating a temporary file in an existing
# directory.

tmpdir=$HOME/tmp/mutt/$LOGNAME$$
umask 077
mkdir "$tmpdir" || exit 1
tmpfile="$tmpdir/${file##*/}"

# Copy mutt's temporary file to our temporary directory so that we can
# let mutt overwrite and delete it when we exit.

cp "$file" "$tmpfile"

# Run the viewer in the background and delete the temporary files when done. 

(
    remsh whiffle -n DISPLAY=$DISPLAY "$viewer" $options "$tmpfile"
    rm -f "$tmpfile"
    rmdir "$tmpdir"
) > $HOME/tmp/$prog.errors 2>&1 &

Reply via email to