Emailing Sql-Ledger Reports using Cron

There is no built-in support in sql-ledger to email reports periodically but you can easily build a shell script which will do so. The trick is to call sql-ledger API through command line to generate the report into an html file and then use mutt to email the report.

For example following call to API from command line will generate the AR Outstanding report to an html file in /tmp folder. (backslash is continuation character)


/usr/local/www/data/sql-ledger/ar.pl "path=bin/mozilla\
&login=armaghan\
&password=armaghan\
&action=continue\
&nextsub=transactions\
&summarY=1&open=Y\
&l_amount=Y\
&l_description=Y\
&l_invnumber=Y\
&l_name=Y\
&l_paid=Y\
&l_transdate=Y\
&vc=customer\
&ARAP=AR\
&outstanding=1" > /tmp/outstanding.html

Once the report is generated, a mutt invocation will send the report to the intended recipient.


/usr/local/bin/mutt -a /tmp/outstanding.html \
-s 'Outstanding report' saqib@ledger123.com < /dev/null

Both these lines can be put into a shell script which can be run periodically through cron.

Leave a Reply