Wednesday, July 28, 2010

back up text files using mail function

#!/bin/bash
# send a file to the email box
# Copyright by http://scriptdemo.blogspot.com
# Note:  
#  don't forget to change the email address to your own

if [ $# -eq 0 ]; then
   echo "usage: mailtome file1 [file2] ..."
   exit
fi

for nf in `seq 1 $#`
do
   eval "filename=\$$nf"
   if [ -f $filename ]; then
      mail -s "[script] $filename" YOUR-NAME@gmail.com < $filename  &&  echo "send mail successfully"
   else
      echo "$filename dos not exist"
   fi
done

No comments:

ShowCalendar