#!/bin/bash # Decoding application/ms-tnef attachements in mail for sylpheed-claws # Author: Shawn Lamson # contributions (like script enhancements etc.), comments, suggestions # etc... accepted at mailto:shawn.lamson@verizon.net # This script depends on you # 1) having tnef installed # http://sourceforge.net/projects/tnef/ # packages are available for all major linux distributions # 2) having x-terminal-emulator or xterm (may need to edit this script # if typing $x-terminal-emulator at a command prompt in X doesn't # give you a xterm console # 3) have bash although sh would probably work too; known issues would # be the "echo -e" and the test [ -z "$VAR" ] wouldnt work with sh # Installation: Read the README.claws section on user actions # for details on how to set up action # 1) put this script somewhere in your executables path and make it # executable. ie. mv tnef-claws /usr/local/bin # chmod +x /usr/local/bin/tnef-claws # 2) here is what my entry in README.claws would be # Purpose: decode ms-tnef attachments in mail # Definition: tnef-claws: x-terminal-emulator -e "tnef-claws" %p # Details: This opens an xterm window to use an interactive # method to extract attachments from ms-tnef encoding # 3) So at least add the part after "Definition:" to your # ~/.sylpheed/actionsrc file # 4) In the message you have received click on the Attachments tab and # highlight the application/ms-tnef line; then go to # Tools/Actions/tnef-claws; the xterm should launch and voila! RAW_NAME= ATTACH_NAME= DEFAULT_DIR=~ ANSWER= # AFAIK there is always going to be a file coming in # but might as well test it if [ -z "$1" ]; then echo -e "No filename/attachment provided! press enter to exit\c" read exit 1 fi RAW_NAME="$1" # # get the name of attachment if any ATTACH_NAME="`tnef -t $RAW_NAME`" # # if there is one - continue if [ $? -ne 0 ] || [ -z "$ATTACH_NAME" ]; then echo -e "\007" echo -e "Nothing in the attachment to extract! press enter to exit\c" read exit 1 fi echo -e "Do you want to extract $ATTACH_NAME ? (Y/n):\c" read ANSWER case ${ANSWER:-y} in Y|y|YES|Yes|yes) ;; *)echo -e "\007" echo -e "Exiting without action ! Press enter to quit\c" read exit 1;; esac # # get the directory to extract to # echo -e "Current dir to extract to is $DEFAULT_DIR; do you want \ to change it? (y/N):\c" read ANSWER case ${ANSWER:-n} in Y|y|YES|Yes|yes) echo -e "Enter the new directory name:\c" read NEW_DIR if [ ! -d "$NEW_DIR" ] || [ ! -w "$NEW_DIR" ]; then echo "Invalid dir !" echo -e "press enter to quit\c"; read exit 1 fi DEFAULT_DIR="$NEW_DIR" ;; *) ;; esac echo -e "The file has been extracted to "$DEFAULT_DIR" as:" # # do the actual extraction # tnef --number-backups -v -C "$DEFAULT_DIR" -f "$RAW_NAME" # # get a confirmation on exit b/c sylpheed claws just quits it # echo -e "press enter to quit\c" read exit 0