reddragdiva: (Default)
[personal profile] reddragdiva

This could be, line for line, the most horrible shell script I have ever perpetrated. At least it admits it.

#!/usr/bin/ksh

# XXX_XXXX_receive
# Receives mail to user mail_in, saves attachments, deletes mail
#
# D. Gerard    17-Jan-2006     First version
#                              This version is horribly inefficient,
#                              but it works and it's very clear what it does.
#                              A more efficient version would process the
#                              mailbox file itself to extract the message.

# This script requires the installation of munpack to decode the attachments
# - see http://www.uwsg.iu.edu/usail/mail/mime/munpack.html
#       http://asg.web.cmu.edu/andrew2/staff/jgm/
#       http://www.sunfreeware.com/programlistsparc8.html#mpack


# this is where our incoming files end up
SAVEDIR=/tmp/XXXX_receive

# is there any mail at all?
if mailx -e -u mail_in
        then

# We have mail.

# Loop through mailbox one message at a time

        while mailx -e -u mail_in
        do

# We go into mailx, print a message and delete it
# note that /home/mail_in/.mailrc contains:
#    set quiet
#    unset header
#    set prompt=""
# Then we extract attachment if any (not text)

        (echo P; echo d; echo q) | mailx -Bn -u mail_in | munpack -C $SAVEDIR

        done

rm /tmp/$$
rm -f $SAVEDIR/*.desc

fi

My geeky readers are about to tell me how I should have done it. But that doesn't account for the law of conservation of programmer mental effort. Besides, this is proprietary software; I have standards to work to.

Re: Totally off topic!

Date: 2006-01-18 12:31 am (UTC)
From: [identity profile] misshavisham.livejournal.com
Thanks so much! I'm really hoping it comes here as well but that could easily be a year away :|

Postal address is

Miss Havisham
PO Box 615
Marrickville
NSW 1475

March 2022

S M T W T F S
  12 345
6789101112
13141516171819
20212223242526
2728293031  

Style Credit

Expand Cut Tags

No cut tags