#!/usr/bin/perl # this script runs through the various bible verses daily # (incrementing number.txt) and mails em out. require '/usr/home/fso/libs/fso-g-lib.pl'; require '/usr/home/em/libs/em-defs.pl'; require '/usr/home/em/libs/em-g-lib.pl'; use lib '/usr/home/em/mod-lib/'; use lib '/usr/home/dntk/mod-lib/'; use Date::Manip; use dntk; use Text::Wrap qw($columns wrap); $columns = 30; my $smtp = new smtp; # TOP_DIR hack $TOP_DIR = "${TOP_DIR}/n_bv"; $| = 1; $DEBUG = 1; $N_DATE = &UnixDate('today', '%m-%d-%Y'); $LIST = "bibleverses"; $CONTENT = "$TOP_DIR/$LIST/verses/kjv"; $REPLYTO = "$LIST-reply\@SoupServer.com"; $OURMAIL = "$LIST\@SoupServer.com"; $BASE = "$SYSURL/daily"; $LAST_MAILED_CONTENT = "last.mailed.content"; # name of file where last send is kept $CHECK_FOR_DUPS = 1; # set it to prevent a dup submission from going through $SUBJECT = "DailyInbox.com - Bible Verse - $N_DATE"; $NUMBER_FILE = "$CONTENT/number.txt"; print "Number_file: $NUMBER_FILE \n"; #exit; open(LOG, ">>/opt/bv_send.log"); $date = `/usr/bin/date`; chomp($date); print LOG "\n-----------------------------\nStarting [bv_alerta.pl] $LIST send run - $date\n"; if ( ! -f $NUMBER_FILE ) { print LOG "Creating number.txt file for the first time.\n"; open(OUT, ">$NUMBER_FILE") or failure("EM - $LIST - couldn't open outfile number.txt"); print OUT "1\n"; close(OUT); } open(IN, "<$NUMBER_FILE") or failure("EM - $LIST - couldn't open infile number.txt"); $CURRENT = ; chomp($CURRENT); if ( $CURRENT !~ /\d+/ ) { # chk to make sure we got a digit or a few failure("EM - $LIST - didn't get a valid number from number.txt"); } close(IN); print LOG "ID: $CURRENT\n"; $NEW = $CURRENT; print LOG "Incrementing number from [$CURRENT] to [$NEW] for this send (has not been stored to disk yet)\n"; if ( length($NEW) == 2 ) { $NEW = '0' . $NEW; } if ( length($NEW) == 1 ) { $NEW = '00' . $NEW; } open(IN, "<$CONTENT/$NEW") or failure("EM - $LIST - couldn't open content file [$CONTENT/$NEW]"); $LINE1 = ; $LINE2 = ; print LOG "Successfully retrieved [$CONTENT/$NEW] for send.\n"; # JMO - Don't need if ( ! $LINE1 ) { print LOG "ERROR: Cannot retrieve content! [$LINE1]\n"; `/usr/local/bin/critsit "BV: Alerta: Cannot retrieve content! [$LINE1]"`; exit; } # print wrap('', '', @tbody); $page = "Daily Bible Verse - $N_DATE\n\n"; $page .= wrap('', '', $LINE1); $page .= "\n$LINE2"; $page .= "\n\n"; $page .= "http://DailyInbox.com\n\n"; open(OUT, ">$LAST_MAILED_CONTENT"); print OUT "$page"; close(OUT); print "$page"; $NEW++; open(OUT, ">$NUMBER_FILE"); print OUT "$NEW\n"; close(OUT); print LOG "Incremented number from [$CURRENT] to [$NEW] on disk.\n"; print LOG "Done.\n\n"; exit;