1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; backgr#!/bin/sh
# Runfetchmail 1.1
#
# Copyright (c) 1997 Doug Muth, Wescosville, Pennsylvania USA
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Please send bug reports, suggestions, and flames to: dmuth@ot.com
#
# This shell script is used as a "frontend" for running fetchmail. It will
# start up fetchmail and save the session to disk, generate statistics
# of the e-mail that you downloaded, and tell you how many messages
# you have in various folders. A copy of these results are also
# e-mailed to you.
#
# An rc file is also supported. If the file $HOME/.runfetchmailrc
# exists, it will be sourced. This way, you can place runfetchmail
# into /usr/local/bin, and individual users can have their own settings.
#
# Pre-requisites: You must have procmail, or at least `mailstat', a
# utility that comes with procmail, running on your system. You must
# also have `timer', a shell script written by me, if you would like the
# total time that the transfer took to be displayed.
#
# Syntax: runfetchmail [-every]
# -every Downloads all messages from the mailserver, regardless of
# their size and whether they have been previously downloaded.
#
# Changes in version 1.1: The argument "-every" is supported. I removed the
# $EXIT_CODE variable since I had problems assigning the exit code from
# fetchmail to it.
# Command line to run fetchmail
FETCHMAIL="/usr/local/bin/fetchmail"
# Your procmail logfile
LOG=$HOME/procmail/log
# Do we want to use timer? Set to 0 to disable.
TIMER=1
# Our path to sendmail with parameters
SENDMAIL="/usr/bin/sendmail -oi -t"
# Who am I?
SELF="dmuth@ot.com"
# The folders that I should check for the number of messages
FOLDERS="$MAIL $HOME/mail/lists"
# Number of seconds to "sleep" for while procmail finishes up, increase
# this if you have a really slow system
LATENT=10
# Do we want to use mailstat? Set to 0 to disable
MAILSTAT=1
# Do we want to e-mail the output to myself? Set to 0 to disable.
# I strongly suggest doing this so that if you lose your connection to
# the net part of the way through a download, you can see how much
# progess was made
E_MAIL=1
###
# End of user defined variables
###
# The temp file, and ensure my privacy!
TMP=/tmp/fetchmail.sh.$$
# The version of this program
VERSION="Runfetchmail 1.1"
# Trap errors
trap "rm -f $TMP; echo ""Exiting at user request"" ; \
test $TIMER -eq 1 && timer -stop -id $$ >/dev/null; exit 1" \
2 3 4 15
# Source the user's rc file if it exists
test -e $HOME/.runfetchmailrc && . $HOME/.runfetchmailrc
num_mail()
{ # This procedure tells me how many messages there are in each folder
for D in $*
do
if test -f $D
then
echo "There are `frm $D |wc -l` messages in $D"
fi
done
}
getmail()
{ # Fetch the mail!
test $TIMER -eq 1 && timer -start -id $$ -quiet
$FETCHMAIL $@
# pause for a short while
echo "Now sleeping for $LATENT seconds..."
echo -n "Zzz...Zzz...Zzz..."
sleep $LATENT
echo "wakeup time! <yawn>"
}
stats()
{ # Prepare the statistics
# Ensure we have a log file
test ! -e $LOG && touch $LOG
echo -e "\n\t\t\t $VERSION Statistics"
test $MAILSTAT -eq 1 && mailstat -k <$LOG
echo ""
num_mail $FOLDERS
test $TIMER -eq 1 && echo -e "\n`timer -stop -id $$ -quiet` have elapsed."
}
prepmail()
{ # Let's prepare our e-mail
cat <<EOF >$TMP
From: $LOGNAME ($VERSION)
To: $LOGNAME
X-Loop: $SELF
Subject: Mail stats from `date "+%D %X"`
EOF
}
### Main Program
# Let's have some initial cleanup
rm -f $LOG
clear
# Create and secure the temporary file
test $E_MAIL -eq 1 && { cat /dev/null >$TMP; chmod 600 $TMP }
# Prepare the e-mail before the logs are added to it
test $E_MAIL -eq 1 && prepmail
# See if we are downloading every message or not
if test "$1" = "-every"
then
FETCHMAIL="$FETCHMAIL -a -l 0"
shift
fi
# Fetch the mail and have the output written to stdout and (optionally) $TMP
test $E_MAIL -eq 1 && getmail $@ 2>&1 |tee -a $TMP || getmail $@
clear
# Do the same thing with the statistics
test $E_MAIL -eq 1 && stats $@ 2>&1 |tee -a $TMP || stats $@
# Now send $TMP to myself and clean up the mess
test $E_MAIL -eq 1 && { cat $TMP |$SENDMAIL; rm -f $TMP }
# cleanup the log file for next time
rm -f $LOG
# The End
|