Eugene Smiley on 7 Nov 2007 01:05:32 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Auto-send Email


Eugene Smiley wrote:
JP Vossen wrote:
From: Eugene Smiley <eug+plug@esmiley.net>
Anyone know of anything that already exists that does this before I go at it?

How about this (untested) shell script in a cron job?

#!/bin/sh -
auto_send=`{ ls -t file_to_send* | tail -n1; } 2> /dev/nul`
[ "$auto_send" ] && cat "$auto_send" | mailx -s 'Subject' user@example.com

Consider it tested. Basically broke it down into parts and watched the result of each piece. Corrected /dev/null. Using mail aliases in .mailrc. Added an rm -f to delete the file only after sending since it won't be needed again.


Final result:
auto_send=`{ ls -t autosendfile* | tail -n1; } 2> /dev/null`
[ "$auto_send" ] && cat "$auto_send" | mail -e -s 'Autosend' list; \
	rm -f "$auto_send"

Works brilliantly. Thanks. And my brain thanks you.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug