Some changes on report_accounts.sh
* s/cat|grep|awk/awk/ * Speak english * Use mktemp
This commit is contained in:
parent
49a476d61c
commit
c7295c6711
1 changed files with 20 additions and 25 deletions
|
|
@ -5,48 +5,43 @@
|
|||
# (Compatible Debian Squeze)
|
||||
# Public domain <BohwaZ>
|
||||
|
||||
SUBJECT="[Banques] Rapport des comptes"
|
||||
TMPSTORAGE="/tmp/"
|
||||
SUBJECT="[Bank] Accounts report"
|
||||
TMPSTORAGE=`mktemp -d`
|
||||
|
||||
rm -f ${TMPSTORAGE}account*
|
||||
boobank -q -f table list > ${TMPSTORAGE}/account_list
|
||||
|
||||
boobank -q -f table list > ${TMPSTORAGE}account_list
|
||||
|
||||
ACCOUNTS=`cat ${TMPSTORAGE}account_list | fgrep '@' | awk '{print $2}'`
|
||||
ACCOUNTS=`awk '/@/ {print $2}' ${TMPSTORAGE}/account_list`
|
||||
|
||||
for i in $ACCOUNTS
|
||||
do
|
||||
boobank -q -f table history "$i" > ${TMPSTORAGE}account_history_${i}
|
||||
boobank -q -f table coming "$i" > ${TMPSTORAGE}account_coming_${i}
|
||||
boobank -q -f table history "$i" > ${TMPSTORAGE}/account_history_${i}
|
||||
boobank -q -f table coming "$i" > ${TMPSTORAGE}/account_coming_${i}
|
||||
done
|
||||
|
||||
echo "Ceci est le rapport des comptes bancaires, généré automatiquement." > ${TMPSTORAGE}account_mail
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
cat ${TMPSTORAGE}account_list >> ${TMPSTORAGE}account_mail
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
echo "Bank accounts report, generated by boobank\n" > ${TMPSTORAGE}/account_mail
|
||||
cat ${TMPSTORAGE}/account_list >> ${TMPSTORAGE}/account_mail
|
||||
echo >> ${TMPSTORAGE}/account_mail
|
||||
|
||||
for i in $ACCOUNTS
|
||||
do
|
||||
echo "Dernières opérations sur le compte $i" >> ${TMPSTORAGE}account_mail
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
cat ${TMPSTORAGE}account_history_${i} >> ${TMPSTORAGE}account_mail
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
if [ -s ${TMPSTORAGE}account_coming_${i} ]
|
||||
echo "Last operations for account $i \n" >> ${TMPSTORAGE}/account_mail
|
||||
cat ${TMPSTORAGE}/account_history_${i} >> ${TMPSTORAGE}/account_mail
|
||||
echo >> ${TMPSTORAGE}/account_mail
|
||||
if [ -s ${TMPSTORAGE}/account_coming_${i} ]
|
||||
then
|
||||
echo "Opérations à venir sur le compte $i" >> ${TMPSTORAGE}account_mail
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
cat ${TMPSTORAGE}account_coming_${i} >> ${TMPSTORAGE}account_mail
|
||||
echo "Coming operations for account $i \n" >> ${TMPSTORAGE}/account_mail
|
||||
cat ${TMPSTORAGE}/account_coming_${i} >> ${TMPSTORAGE}/account_mail
|
||||
echo >> ${TMPSTORAGE}/account_mail
|
||||
else
|
||||
echo "Pas d'opération à venir sur le compte $i" >> ${TMPSTORAGE}account_mail
|
||||
echo "No coming operation for $i \n" >> ${TMPSTORAGE}/account_mail
|
||||
fi
|
||||
echo >> ${TMPSTORAGE}account_mail
|
||||
done
|
||||
|
||||
if [ "$1" = "--mail" ]
|
||||
then
|
||||
cat ${TMPSTORAGE}account_mail | mail -s "$SUBJECT" -a "Content-type: text/plain; charset=UTF-8" "$2"
|
||||
cat ${TMPSTORAGE}/account_mail | mail -s "$SUBJECT" -a "Content-type: text/plain; charset=UTF-8" "$2"
|
||||
else
|
||||
cat ${TMPSTORAGE}account_mail
|
||||
cat ${TMPSTORAGE}/account_mail
|
||||
fi
|
||||
|
||||
rm -f ${TMPSTORAGE}account*
|
||||
rm -rf ${TMPSTORAGE}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue