Created
May 20, 2009 01:15
-
-
Save doitian/114543 to your computer and use it in GitHub Desktop.
send daily report
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#################### | |
# Configs | |
##### | |
VAR_NAME='First Last' | |
VAR_ADDR='[email protected]' | |
# cc to me ? yes/no | |
VAR_CC_ME='yes' | |
# send to me instead of boss for debug? yes/no | |
VAR_DEBUG='no' | |
VAR_BOSS_NAME='Boss Name' | |
VAR_BOSS_ADDR='[email protected]' | |
if [ -n "$VAR_DEBUG" ] && [ "$VAR_DEBUG" = 'yes' ]; then | |
VAR_BOSS_NAME="$VAR_NAME" | |
VAR_BOSS_ADDR="$VAR_ADDR" | |
fi | |
#################### | |
# App start | |
##### | |
usage () { | |
echo "$0 file" | |
echo 'or' | |
echo "cat file | $0" | |
} | |
if [ -n "$1" ] && [ "$1" != '-' ]; then | |
if [ "$1" = '-h' ] || [ "$1" = '--help' ]; then | |
usage | |
exit | |
fi | |
if ! [ -f "$1" ]; then | |
echo "cannot find file $1" 1>&2 | |
exit 1 | |
fi | |
exec <"$1" | |
fi | |
VAR_BODY="`cat`" | |
if [ "$VAR_BODY" = "" ]; then | |
echo 'no message!' 1>&2 | |
exit 1 | |
fi | |
VAR_HEADER="Subject: Daily Report - `date +'%Y.%m.%d'` - $VAR_NAME | |
From: \"$VAR_NAME\" <$VAR_ADDR> | |
To: \"$VAR_BOSS_NAME\" <$VAR_BOSS_ADDR>" | |
VAR_CC_ME_MAYBE= | |
if [ -n "$VAR_CC_ME" ] && [ "$VAR_CC_ME" = 'yes' ]; then | |
VAR_HEADER="$VAR_HEADER | |
CC: \"$VAR_NAME\" <$VAR_ADDR>" | |
VAR_CC_ME_MAYBE="$VAR_ADDR" | |
fi | |
echo "$VAR_HEADER | |
Dear $VAR_BOSS_NAME, | |
$VAR_BODY | |
------------------------------ | |
Sincerely, $VAR_NAME | |
. | |
" | sendmail "$VAR_BOSS_ADDR" "$VAR_CC_ME_MAYBE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment