Posted By

rkumar on 09/02/10


Tagged

script


Versions (?)

mail a file as attachment command line


 / Published in: Bash
 

  1. #!/bin/bash
  2. ## vim:ts=4:sw=4:tw=100:ai:nowrap:formatoptions=croqln:
  3. file=${1}
  4. echo -n "Enter body:"
  5. read body
  6. echo -n "Enter Subject: "
  7. read subject
  8. [[ -z "$body" ]] && { body="Sending attachment using mail"; }
  9. [[ -z "$subject" ]] && { subject="backup: $file "; }
  10. [[ -z "$file" ]] && { echo "Error: file blank." 1>&2; exit 1; }
  11. { echo -e "$body"; uuencode "$file" "$file"; } | mail -s "$subject" ${GMAIL_USER}@gmail.com ;
  12.  

Report this snippet  

You need to login to post a comment.