Bei die ganzen Gewinnspiele, die ins elektronische Postfach flattern, schicken wir uns doch zur Abwechslung selber mal ein bisschen Spam. Da kommt die stündliche Verlosung beim Tagesspitzel doch wie gerufen. Um also nicht ständig von der Arbeit abgelenkt zu werden, automatisieren wir das ganze und warten einfach ab, bis Fortuna uns hold sein möge.
5 8-17 9-19 2 * php gewinnspiel.php
<?
#gewinnspiel.php
Header('Content-Type:text/plain');
$domain = "http://static.tagesspiegel.de/service/yorck-gewinnspiel/gewinner.html";
$ch = curl_init($domain);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$pattern = '/(<span style=\"font-size:24pt;\">)(\D\D\d\d\d\d)/';
preg_match($pattern, $response, $matched);
$mycode = "LN1224";
$result = strcmp($matched[2],$mycode) ;
if ($result==0) {
exec('osascript send-mail.applescript spamtrap@fiasko.in-berlin.de yorck-gewinnspiel Gewonnen!');
}
else {
exec('osascript send-mail.applescript spamtrap@fiasko.in-berlin.de yorck-gewinnspiel "Leider nicht gewonnen"');
}
?>
(* send-mail.applescript *)
on run argv
tell application "Mail"
set toVar to item 1 of argv
set subjectVar to item 2 of argv
set bodyVar to item 3 of argv
set composeMessage to make new outgoing message
tell composeMessage
make new to recipient with properties {address:toVar}
set the subject to subjectVar
set the content to bodyVar
set visible to false
end tell
send composeMessage
end tell
end run
Ein Kommentar zu „crontab -e“