JP Vossen on 6 Nov 2007 21:31:18 -0000


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

Re: [PLUG] Auto-send Email


Date: Tue, 06 Nov 2007 13:25:36 -0500
From: Eugene Smiley <eug+plug@esmiley.net>
>
Ok, so my brain isn't really working too well today.

I know that feeling. :-)


I need a solution to auto-send a text file (if it exists) as an email at a specific time. If more than one file exists. I only want the oldest one sent.

I know I can use cron and mailx, since this is what I do for pflogsumm.pl. I guess I could write a couple of quick Perl lines to figure out the conditionals.

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


<shameless plug>
If this kind of thing comes up a lot, you might be interested in the _bash Cookbook_... :-)
</shameless plug>



HTH, JP ----------------------------|:::======|------------------------------- JP Vossen, CISSP |:::======| jp{at}jpsdomain{dot}org My Account, My Opinions |=========| http://www.jpsdomain.org/ ----------------------------|=========|------------------------------- Microsoft has single-handedly nullified Moore's Law. Innate design flaws of Windows make a personal firewall, anti-virus and anti-malware software mandatory. The resulting software arms race has effectively flattened Moore's Law on hardware running Windows. ___________________________________________________________________________ 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