
#!/bin/sh
# File	: get_dfm-options.sh
# By	: Maarten de Boer, 141021
# Subject	: Scripts to get the list of DFM-options & put into .CSV
#(0.2), 210531	: Mod. MAILTO <> "", CSV(-name) & DATI
#
PGM="`basename $0|cut -d\. -f1`"
VER="0.2"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
MAILTO="maarten.deboer@atos.net"
HOSTNAME="`hostname|cut -d\. -f1`"
DATI="`date +%Y-%m-%d-%H-%M`"
CSV="${HOME}/etc/dfm-options_${HOSTNAME}_${DATI}.csv"

touch ${TMP}
echo "CSV=${CSV}"
echo "MAILTO=${MAILTO}"
echo "`date` ${PGM} v${VER} started"|tee -a ${LOG}

/usr/bin/dfm options list|awk -v HOSTNAME=$HOSTNAME '{print HOSTNAME";"$1";"$2";"$3";"}' > ${CSV}
if [ "${MAILTO}" != "" ]; then
  date | mailx -a ${CSV} -s "dfm options list" ${MAILTO}
  echo "  Mailed the 'dfm options list' (${CSV}) to ${MAILTO}"|tee -a ${LOG}
fi

rm ${TMP}
exit 0

