Here's a beta version of code that I made for myself. My desktop is a Windows system, but I run mutt through SSH. I'd like to be able to have HTML and image attachments come up directly on my web browser, so I made this code.
Prerequisites: - mutt (of course!) - SecureCRT SSH client (or other SSH client with ZMODEM and Visual Basic scripting support; opera.vbs may need minor modifications to work with other clients) - ZMODEM installed on your UNIX system as the "sz" command To install it, put opera.pl in ~/bin/opera and chmod 755. Then, put this into your ~/.mailcap (customize to your liking): text/html; opera html %s image/gif; opera gif %s image/jpg; opera jpg %s image/jpeg; opera jpg %s image/pjpeg; opera jpg %s image/png; opera png %s The script called "opera" will rename the attachment file to a unique value ($ARGV[0] is the extension that it will use), and then execute the "sz" command to send the file to your SSH client. After doing so, it will print "$filename\n$passphrase\n". On your SSH client, you will need to have opera.vbs running. SecureCRT can be set to always run this script automatically if you configure it in Options->Session Options->Connection->Login Scripts. opera.vbs will listen for $passphrase and when it hears it, it will open the file in $path/$filename (be sure that you have set Windows to know to use your favorite program to open .JPG, .PNG, .GIF, .HTML). You probably want to change $passphrase in opera.pl and opera.vbs (they must match) to some secret value, and don't set it to be world readable. Another hint if you have a slow link: For faster download of certain files e.g. (HTML, DOC, XLS), in SecureCRT go to Options->Session Options->Connection->SSH2->Compression, and check "Use compression" and crank "Compression level" up to 9. If anyone uses this/improves on it, let me know. :) For loading HTML attachments, I'm thinking it might be useful to load it in lynx first, and then have the option of opening it on my desktop instead if lynx is inadequate... is there a way to define multiple possible actions for a single MIME type? I also wonder if I can make it so that when I click a "mailto:" link in my desktop web browser, it goes to mutt and automatically starts composing a message. I probably won't bother doing this though, because I'm not familiar with VBScript programming, and there's also the problem of how to interface with mutt - what if it's not running, what if it's in the middle of composing another message, etc.
#!/usr/bin/perl # This program is free software under the GNU Public License. # See http://www.gnu.org/copyleft/gpl.html for details. # A wrapper script intended for use in .mailcap in order to send # files to the desktop web browser when running applications # over SSH or telnet. The SSH/telnet client must have special # programming instructions in order for this to work. use strict; use File::Basename; my $passphrase = "SPECIAL TRIGGER STRING"; # Check for valid command line arguments die "Usage: opera <extension> <filename>" unless @ARGV == 2; my ($ext, $file) = @ARGV; die "Cannot read/write $file" unless (-R $file && -W $file); # Generate new unique filename with correct extension my $dirname = dirname($file); my $time = time; my $newbase = "dl_${time}_$$.$ext"; my $newfile = "$dirname/$newbase"; rename($file, $newfile) || die "Cannot rename $file to $newfile"; # Upload file to desktop and delete it locally system("sz $newfile"); unlink $newfile; # Send command string to client, triggering it to open the file print "$newbase\n$passphrase\n";
opera.vbs.gz
Description: gzipped .VBS script; run in SecureCRT