#!/bin/sh # # Backup a file by sending it to Gmail or Yahoo # ADDR=mats.peterson@gmail.com MAXSIZE=7340032 usage() { echo "usage: $(basename $0) [-{1-8}] file [subject]" >&2 exit 1 } while getopts ":12345678" c do case "$c" in 1) ADDR=ybak001@yahoo.com;; 2) ADDR=ybak002@yahoo.com;; 3) ADDR=ybak003@yahoo.com;; 4) ADDR=ybak004@yahoo.com;; 5) ADDR=ybak005@yahoo.com;; 6) ADDR=ybak006@yahoo.com;; 7) ADDR=ybak007@yahoo.com;; 8) ADDR=ybak008@yahoo.com;; :|'?') usage;; esac done shift $(($OPTIND - 1)) [ $# -eq 0 ] && usage subject=$1; [ $# -gt 1 ] && subject=$2 size=$(ls -l "$1" | nawk '{print $5}') if [ $size -gt $MAXSIZE ]; then split -b $MAXSIZE "$1" "$1"- for f in "$1"-*; do eval "ndx=\${f##$1-}" echo "Sending $f..." mmsend $ADDR "$subject $ndx" "$f" done rm -f "$1"-* else echo "Sending $1..." mmsend $ADDR "$subject" "$1" fi .