
#/bin/sh
# File	: mail_crontab_in_csv.sh
# By	: Maarten.deBoer@atos.net, 120205
# Subject	: List crontab in .CSV-format WITHOUT remarks (#), change -options in '- options (for Excell-ERROR) & mail this
#set -x
PGM="`basename $0|cut -d\. -f1`"
TMP="/tmp/${PGM}.$$"
MAILTO="maarten.deboer@atos.net"
HOSTNAME="`hostname|cut -d\. -f1`"
DATI="`date +%Y%m%d_%H%M%S`"
CSV="crontab-${HOSTNAME}-${USER}-${DATI}.csv"

# List crontab WITHOUT remarks (#)
crontab -l | grep -v "^#"|awk '{print $1";"$2";"$3";"$4";"$5";"$6";"$7";"$8";"$9";"$10";"$11";"$12";"$13";"}'|sed "s/\;-/\;'-/g"|uuencode ${CSV} | mailx -s ":${HOSTNAME}: [${PGM}]" ${MAILTO}
echo "Mailed crontab (-l) in ${CSV} to ${MAILTO}"

exit 0

