1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 08:12:48 +01:00
imapsync/W/paypal_reply/paypal_send_invoices
Nick Bebout 1b3773e80f 1.456
2011-09-25 15:31:48 -05:00

57 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
# $Id: paypal_send_invoices,v 1.7 2011/07/14 12:31:44 gilles Exp gilles $
# usages:
# sh paypal_send_invoices /g/var/paypal_invoices/147
# sh paypal_send_invoices /g/var/paypal_invoices/15?
send_invoice() {
test X"" = X"$1" && { echo "usage: send_invoice /g/var/paypal_invoices/147 vince@norestech.net"; return; }
d="$1"
echo "====== $d ======"
#echo
cd $d || return
bd=`basename $d`
#echo "$bd"
invoice="$bd"
if test -f WAIT_DONT_SEND; then
echo "found WAIT_DONT_SEND in $d then exit"
continue
fi
test -f facture_imapsync-${invoice}.pdf || { echo NO facture_imapsync-${invoice}.pdf ; return; }
test -f facture_imapsync-${invoice}.pdf.asc || { echo NO facture_imapsync-${invoice}.pdf.asc ; return; }
test -f facture_message_header.txt || { echo NO facture_message_header.txt ; return; }
test -f facture_message_body.txt || { echo NO facture_message_body.txt ; return; }
test -f email_address.txt || { echo NO email_address.txt ; return; }
email=${2:-`cat email_address_2.txt || cat email_address.txt`}
> facture_message_to.txt
egrep '^To: ' facture_message_header.txt > /dev/null || echo "To: $email" > facture_message_to.txt
cat facture_message_header.txt facture_message_to.txt facture_message_body.txt > facture_message.txt
more facture_message.txt
echo '====== END of message ======'
test -f "SENT_TO_$email" && {
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
echo "!!! Already SENT_TO_$email"
echo '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
}
mailq
test -f "SENT_TO_$email" || acroread facture_imapsync-${invoice}.pdf&
echo "Send this invoice ${invoice} to $email?"
read r < /dev/tty
echo SAID "[$r]"
test X"$r" = Xy && {
echo | mutt -H facture_message.txt -a facture_imapsync-${invoice}.pdf facture_imapsync-${invoice}.pdf.asc --
touch SENT_TO_$email
}
}
echo $0 '/g/var/paypal_invoices/99?'
for d in "$@"; do
( send_invoice "$d" )
done