Re: mailx / sendmail command
Posted in 2006
Here you go. This will send the file as an attachment. The variable msg is used in the subject. function techMail { endDate=$(date) command=${1} logfile=${2} typeset -i status=${3} typeset -i2 severity=4 host=$(hostname) user=${LOGNAME:-unknown} case ${status} in 0) msg="Completed Successfully" severity=1 ;; 111) msg="Completed with Warnings" severity=2 ;; *) msg="Completed with FAILURES" severity=4 ;; esac cat >> ${logfile} <<EOF ############################################################################## ${msg} on ${endDate} ############################################################################## EOF # # REMEMBER its a bitwize comparison!!! Also remember that shell treats 0 as # TRUE~). # [ $((${severity} & ${MSG_SEVERITY})) -eq 0 ] && return 0 /usr/sbin/sendmail ${MAILTO} <<EOF From: ${user}@${host} To: ${MAILTO} Subject: CRON(${command}): ${msg}. Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="DMW.Boundary.605592468" --DMW.Boundary.605592468 Content-Type: application/octet-stream; name="$logfile" Content-Disposition: attachment; filename="$logfile" Content-Transfer-Encoding: 7bit $(cat ${logfile}) --DMW.Boundary.605592468-- EOF return ${?} } > Can anyone provide the command how to send a text file as a attachment > with a > proper subject using mailx or sendmail command in UNIX. > > Note: I am using HP-UX OS. The file send should be the attachment, not in > the > message body. In addition, I need to put in the mail subject as well. > > -- > Message posted via DBMonster.com > http://www.dbmonster.com/Uwe/Forums.aspx/informix/200607/1 > _______________________________________________ > Informix-list mailing list > Informix-list@iiug.org > http://www.iiug.org/mailman/listinfo/informix-list >