[Zope] Automate an e-mail script

Chris Beaumont cbeaumon@msri.org
Sun, 25 Mar 2001 18:13:27 -0800


Hi Erik

Are you on Linux?
if so, read on...

If you can set it up so a http request to a method triggers your 
event, you can use the Unix utility cron with the text-based browser 
'lynx' to do this. Have it write the resultant output file to 
/dev/null if you want... and get the file at regular intervals.. in 
other words, use this to trigger dtml-sendmail.

I do this to send a listing of events at a certain time every week..

This technique is also *really* useful to make it possible to use 
(static versions of) Zope content on other machines easily...  use 
lynx in -source mode to grab the file from Zope over the web, and 
then write the file into the other machines' web document tree, 
always using the same filename.  For content that changes, you could 
have the cron job get the Zope page say every half hour or so... This 
technique is quite reliable (if failure would cause problems, have 
cron trigger a shell script to do the actual job, and have the script 
not write any file if the get fails..) and also offers some slight 
performance advantages for a heavily-trafficked site..especially with 
images.. (although I think the various Zope-based solutions are 
pretty fast in their own right..)

One thing.. lynx gets confused running from cron because unless you 
set it up that way, it doesn't have a terminal type to go by..(this 
is important for curses-based programs..) so give it a terminal type 
of 'vt102' or some such on the command line..(this is the common 
gotcha - how varies with your shell, in bash you just state it before 
the lynx command..i.e. TERM=vt102 ) and it will happily churn away...

Here's how its done in the crontab..
(note that this is all one line even though it might wrap in your email client)

30 14 * * 3 TERM=vt102 lynx -source 
http://127.0.0.1/path/to/dtml_method > /tmp/discard_this_file


This example triggers the task at 2:30 every Tuesday afternoon, 
writing the source of the resultant page out to the /tmp directory 
each time..where it can safely be ignored forever... (if security is 
an issue, use /dev/null, basically the Unix equivalent of a black 
hole....)

There's a how-to on this technique somewhere on Zope.org if you dig around..

Good luck!

Chris Beaumont
cbeaumon@msri.org


>Hello there,
>
>I have written a script that will generate a list of all the files that are
>more than a year old in zope, and e-mails this list to someone who cares.
>  I was wondering if there was a way that I could automate this script so
>that it ran every morning without having someone run it manually.
>
>Thanks Eric
>
>_______________________________________________
>Zope maillist  -  Zope@zope.org
>http://lists.zope.org/mailman/listinfo/zope
>**   No cross posts or HTML encoding!  **
>(Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )