Georgios Vetoulis <vetoulis(_at_)pppl(_dot_)gov> writes:
I have a question that must have bothered the members of this list
so here it goes:
No, not particularly. :-)
...
How can I use that main account as a pop server? There are some rather
severe limits on my connect time, so I would like to be able to
connect, and then using something like rcp or whatever, grab the
mailboxes from the main account and transfer their contents to the
corresponding mailboxes in my Linux account at home. I guess the real
question is locking. How do I ensure that I am not loosing mail when
grabbing a mailbox that procmail wants to write in?
I'd suggest IMAP, but that's either overkill or arguably not even a
solution, as you still remain connected. In order to handle the locking,
you'll need to lean towards rsh rather than rcp, where your wrapper
script on the local end would look something (this is untested) like:
#!/bin/sh
# Given a mailbox name, where is it located on the remote and local systems?
rmailbox=/my/maildir/on/the/other/system/Mail/$1
lmailbox=$HOME/Mail/$1
# If we've transfered the mail but can't lock the local mailbox, drop the
# the mail where? WARNING: we don't even bother trying to lock this, so
# it should probably contain $$ (our pid) to be semi-unique.
fallback=$lmailbox.$$.
# The big ugly command for remote side shown here does the remote lock,
# and if it succeeds, sends over the mailbox, then truncates and unlocks
# it. The first line sent back is always the return code of the lockfile
# command.
rsh -n mailserver "/bin/sh -c 'if lockfile $rmailbox.lock; then echo 0; cat
$rmailbox; cp /dev/null $rmailbox; rm -f $rmailbox.lock; else echo \$?; fi'" |
(
# Get the status
read status;
# Well?
if test 0 -eq $status; then
if lockfile $lmailbox.lock; then
cat - >> $lmailbox
rm -f $lmailbox.lock
else
echo "Unable to lock $lmailbox, status = $?" >&2
cat - >> $fallback
echo "Mail saved in $fallback" >&2
fi
else
echo "lockfile failed on remote side, status = $status" >&2
fi
)
The evil trick of the above is to make the first line sent back from the
remote host be the status of the lockfile command over there. This way
we can catch that case and warn about it, without trying to append anything
to the local mailbox.
Philip Guenther