First, I wish to thank Thomas E. Dodd <[EMAIL PROTECTED]> for his
encouragement, and a few suggestions on how to do this.  He got me over
the frustration hurdle.  Thanks Thomas.

What follows is a script file (in csh, because that's what I'm most
comfortable with) to dial into an Email provider, pickup and send Email,
and then logout again.  I just tested it, from cron, and it works great
(for me).  If it works for you too, I will be very pleased.  Please let
me know.
-----------------------------------------------------------------------
#!/bin/csh -f
#
#  go_fetch_mail is written to use the ppp1 interface, as setup in a
#  RedHat environment (mine is V5.1), to automatically dial into your
#  Email provider, and fetch both SMTP and POP mail.  It assumes that
#  root has a properly configured .fetchmailrc in it's home directory.
#  This script will also force sendmail to ship out any local Email
#  that was queued because your link was down.
#
#  Note that if your link is up when this routine runs, this script
#  will exit without doing anything.
#
#  Designed for use by cron.  Put this script file in /usr/local/bin, and
#  put a line like the following in /etc/crontab
#
#  15 2,8,12,16,20 * * * root /usr/local/bin/go_fetch_mail
#
#  etrn.pl is a perl script file, the latest version of which is 
#  available in the contrib directory of the sendmail distribution.
#
set email_server=email.vnet.net
set Device="ppp1"
set if_device="ppp0"
#
if (`ifconfig | grep ${if_device}` != "") then
  exit
endif
set file_size=`ls -l /var/log/maillog |awk '{print $5}'`
ifup ${Device}
sleep 45
set foo=`ifconfig | grep ${if_device}`
while ("${foo}" == "")
  sleep 10
  set foo=`ifconfig | grep ${if_device}`
end
/usr/sbin/sendmail -q
/usr/local/bin/etrn.pl ${email_server}
/usr/bin/fetchmail --batchlimit 1000
set NeW=`ls -l /var/log/maillog |awk '{print $5}'`
while (${file_size} != ${NeW})
  set file_size=${NeW}
  sleep 30
  set NeW=`ls -l /var/log/maillog |awk '{print $5}'`
end
ifdown ${Device}
exit


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
http://www.redhat.com/RedHat-FAQ /RedHat-Errata /RedHat-Tips /mailing-lists
         To unsubscribe: mail [EMAIL PROTECTED] with 
                       "unsubscribe" as the Subject.

Reply via email to