Re: [Koha] How to receive reports to email
Hi Satish Always CC koha list so you can have more feedbacks and others can profit from discussion. You can start with the example Paul provided. I don't know perl but seems complete; however you need to define/create your query. If you don't know perl, you can use any language you know. You can place it in any where you want -you must add-its path to the cron line-. Koha have a cgi-script folder you might want to use or create one for your specific scripts. It must also have the permissions required for it to be run by your cron and access your database. As Paul said, once you have your script ready you need to add a line in your daily cron for it to execute. Regards, Alvaro |-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com Le ven. 15 févr. 2019 à 01:16, SATISH <lis4satish@gmail.com> a écrit :
Hi Alvaro,
Thank you for your email, could you please do little elaborate on how to write a script or could share some example script. Where this script should be placed (path) and permissions.
Tks. Satish
On Thu, 14 Feb 2019 at 19:03, Alvaro Cornejo <cornejo.alvaro@gmail.com> wrote:
Hi
If already have an report for this, you can define it as public and create a small script -in the language of your choice- that runs it and insert an entry in cron jobs.
You can even create the whole report in your script accessing directly to your database.
Regards,
Alvaro
There is already the runreport.pl cronjob that can do this. https://koha-community.org/manual/18.11/en/html/cron_jobs.html#run-report Le 19-02-15 à 10 h 28, Alvaro Cornejo a écrit :
Hi Satish
Always CC koha list so you can have more feedbacks and others can profit from discussion.
You can start with the example Paul provided. I don't know perl but seems complete; however you need to define/create your query. If you don't know perl, you can use any language you know.
You can place it in any where you want -you must add-its path to the cron line-. Koha have a cgi-script folder you might want to use or create one for your specific scripts. It must also have the permissions required for it to be run by your cron and access your database.
As Paul said, once you have your script ready you need to add a line in your daily cron for it to execute.
Regards,
Alvaro |-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com
Le ven. 15 févr. 2019 à 01:16, SATISH <lis4satish@gmail.com> a écrit :
Hi Alvaro,
Thank you for your email, could you please do little elaborate on how to write a script or could share some example script. Where this script should be placed (path) and permissions.
Tks. Satish
On Thu, 14 Feb 2019 at 19:03, Alvaro Cornejo <cornejo.alvaro@gmail.com> wrote:
Hi
If already have an report for this, you can define it as public and create a small script -in the language of your choice- that runs it and insert an entry in cron jobs.
You can even create the whole report in your script accessing directly to your database.
Regards,
Alvaro
Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
-- Caroline Cyr La Rose, M.L.I.S. Librarian | Product Manager Phone: 1-833-465-4276, ext. 221 Caroline.Cyr-La-Rose@inLibro.com <mailto:caroline.cyr-la-rose@inLibro.com> INLiBRO | Document Technologies Specialists | www.inLibro.com <http://www.inLibro.com>
Hi Caroline, Thank you for your email. Could you please confirm, the format I am using in cron is it correct? #test report 30 17 __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to= lis4satish@gmail.com Also, I would like to get the report in - tab delimited format or csv format. Thank you Satish
Hi I guess you should use .... --format=cvs ... and maybe --cvs-header Regards, Alvaro |-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com Le sam. 16 févr. 2019 à 02:50, SATISH <lis4satish@gmail.com> a écrit :
Hi Caroline,
Thank you for your email.
Could you please confirm, the format I am using in cron is it correct?
#test report 30 17 __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to= lis4satish@gmail.com
Also, I would like to get the report in - tab delimited format or csv format.
Thank you Satish _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
Hi You need to specify all time fields in your command. If you do not want to specify one, you must insert an * Time fields are [minute] [hour] [day] [month] [day of week] 30 17 * * * __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=cvs --to=lis4satish@gmail.com As per above, your report will run every day al 17:30hrs. Regards Alvaro |-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com Le lun. 18 févr. 2019 à 09:25, Alvaro Cornejo <cornejo.alvaro@gmail.com> a écrit :
Hi
I guess you should use .... --format=cvs ... and maybe --cvs-header
Regards,
Alvaro
|-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com
Le sam. 16 févr. 2019 à 02:50, SATISH <lis4satish@gmail.com> a écrit :
Hi Caroline,
Thank you for your email.
Could you please confirm, the format I am using in cron is it correct?
#test report 30 17 __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to= lis4satish@gmail.com
Also, I would like to get the report in - tab delimited format or csv format.
Thank you Satish _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
note that the format should be --format=csv (comma separated values) not --format=cvs On Mon, Feb 18, 2019 at 9:33 AM Alvaro Cornejo <cornejo.alvaro@gmail.com> wrote:
Hi
You need to specify all time fields in your command. If you do not want to specify one, you must insert an *
Time fields are [minute] [hour] [day] [month] [day of week]
30 17 * * * __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=cvs --to=lis4satish@gmail.com
As per above, your report will run every day al 17:30hrs.
Regards
Alvaro
|-----------------------------------------------------------------------------------------------------------------| Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com
Le lun. 18 févr. 2019 à 09:25, Alvaro Cornejo <cornejo.alvaro@gmail.com> a écrit :
Hi
I guess you should use .... --format=cvs ... and maybe --cvs-header
Regards,
Alvaro
|-----------------------------------------------------------------------------------------------------------------|
Envíe y Reciba Datos y mensajes de Texto (SMS) hacia y desde cualquier celular y Nextel en el Perú, México y en mas de 180 paises. Use aplicaciones 2 vias via SMS y GPRS online Visitenos en www.perusms.com
Le sam. 16 févr. 2019 à 02:50, SATISH <lis4satish@gmail.com> a écrit :
Hi Caroline,
Thank you for your email.
Could you please confirm, the format I am using in cron is it correct?
#test report 30 17 __KOHA_USER__ $KOHA_CRON_PATH/runreport.pl 141 --format=text --to= lis4satish@gmail.com
Also, I would like to get the report in - tab delimited format or csv format.
Thank you Satish _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
_______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
Thank you Paul, Barton, Alvaro Still I am not able to run the said scripts. I am getting same permission problem. I tried to keep related files in /root directory and also in /usr/share/koha/bin directory same permission problem occurs. So, I did not understand it completely. I need some more guidance to get desired results. However, I also tried with other suggestions given in the mail, since runreports.pl is already defined in koha, I directly edited the file -- koha-common (etc/cron.d) added following line, 45 17 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl report-id --format=html --to=email id I am successful. But, for multiple reports, I am not successful. 45 17 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2 report-id3 --format=html --to=email id Checkout report - is taken from SQL library, developed by Sarah Cornel List of items issued on a date with optional limit by due date <https://wiki.koha-community.org/wiki/SQL_Reports_Library#List_of_items_issued_on_a_date_with_optional_limit_by_due_date> with little modification in the last line, manual entry of 'issue date' to 'current date' to chose date on which report is run. SQL ------------------------------ SELECT issuedate, date_due, items.barcode, items.itemcallnumber, biblio.title, biblio.author, CONCAT(borrowers.firstname, ' ',borrowers.surname) AS 'patron', borrowers.cardnumber, CONCAT(borrowers.borrowernumber) AS borrowernumber FROM issues LEFT JOIN items ON issues.itemnumber = items.itemnumber LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber WHERE DATE(issuedate) = CURDATE() ------------------------------- Since I missed to CC koha forum, I am copying imp mails from Paul received. -- The twiddle character (~) in the koha-shell command is being interpreted as root's home directory (/root), not as the regular user's home directory (/home/helm-gechlibrary or whatever). The regular user can't see inside /root, hence the permission error. Try this: # koha-shell gechlibrary -c '/home/helm-gechlibrary/bin/run-reports.pl /home/helm-gechlibrary/reports/checkout-report.txt' Or, equivalently: # koha-shell gechlibrary -c '~helm-gechlibrary/bin/run-reports.pl ~helm-gechlibrary/reports/checkout-report.txt' This should also work: # koha-shell gechlibrary --login -c 'bin/run-reports.pl reports/checkout-report.txt' That's because the command -- i.e., the COMMAND in _koha-shell INSTANCE --login -c COMMAND_ -- is executed by a process whose current working directory is /home/helm-gechlibrary. Good luck! Paul. ---
Hi Satish, try to add multiple lines in crontab for the different reports you want to run. I think the runreport.pl script only can only be run with one report number at a time. Katrin On 06.03.19 12:53, SATISH wrote:
Thank you Paul, Barton, Alvaro
Still I am not able to run the said scripts. I am getting same permission problem. I tried to keep related files in /root directory and also in /usr/share/koha/bin directory same permission problem occurs. So, I did not understand it completely. I need some more guidance to get desired results.
However, I also tried with other suggestions given in the mail, since runreports.pl is already defined in koha,
I directly edited the file -- koha-common (etc/cron.d) added following line,
45 17 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl report-id --format=html --to=email id I am successful.
But, for multiple reports, I am not successful. 45 17 * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2 report-id3 --format=html --to=email id
Checkout report - is taken from SQL library, developed by Sarah Cornel List of items issued on a date with optional limit by due date <https://wiki.koha-community.org/wiki/SQL_Reports_Library#List_of_items_issued_on_a_date_with_optional_limit_by_due_date> with little modification in the last line, manual entry of 'issue date' to 'current date' to chose date on which report is run.
SQL ------------------------------ SELECT issuedate, date_due, items.barcode, items.itemcallnumber, biblio.title, biblio.author, CONCAT(borrowers.firstname, ' ',borrowers.surname) AS 'patron', borrowers.cardnumber, CONCAT(borrowers.borrowernumber) AS borrowernumber FROM issues LEFT JOIN items ON issues.itemnumber = items.itemnumber LEFT JOIN biblio ON items.biblionumber = biblio.biblionumber LEFT JOIN borrowers ON issues.borrowernumber = borrowers.borrowernumber WHERE DATE(issuedate) = CURDATE() -------------------------------
Since I missed to CC koha forum, I am copying imp mails from Paul received. -- The twiddle character (~) in the koha-shell command is being interpreted as root's home directory (/root), not as the regular user's home directory (/home/helm-gechlibrary or whatever). The regular user can't see inside /root, hence the permission error.
Try this:
# koha-shell gechlibrary -c '/home/helm-gechlibrary/bin/run-reports.pl /home/helm-gechlibrary/reports/checkout-report.txt'
Or, equivalently:
# koha-shell gechlibrary -c '~helm-gechlibrary/bin/run-reports.pl ~helm-gechlibrary/reports/checkout-report.txt'
This should also work:
# koha-shell gechlibrary --login -c 'bin/run-reports.pl reports/checkout-report.txt'
That's because the command -- i.e., the COMMAND in _koha-shell INSTANCE --login -c COMMAND_ -- is executed by a process whose current working directory is /home/helm-gechlibrary. Good luck! Paul. --- _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
Hi Katrin, I verified for multiple reports today. It is working fine. The correct syntax: * * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl report-id1 report-id2 report-id3 --format=html --to=email id (report ids separated by one space only, no semicolon, no comma) Since, I had an extra (star)* character in my cron entry earlier by typo error, caused cron not to send emails. thank you everyone for your guidance. With best regards. -- *Satish MV* M.Sc, PGDCA, UGC-NET, Librarian - Govt. Engineering College Opp. Dairy Circle, B.M.Road, Hassan 573 201 Karnataka, INDIA Mobile: +91 9449765737 Personal Email: lis4satish@gmail.com College Website: www. <http://www.git.edu/>gechassan.ac.in Library OPAC: http://library.gechassan.ac.in Library Portal : https://librarygechassan.wixsite.com/library
Hi Satish, thx for the update. Good to know! Katrin On 08.03.19 12:37, SATISH wrote:
Hi Katrin,
I verified for multiple reports today. It is working fine.
The correct syntax: * * * * * root koha-foreach --enabled --email /usr/share/koha/bin/cronjobs/runreport.pl <http://runreport.pl/> report-id1 report-id2 report-id3 --format=html --to=email id (report ids separated by one space only, no semicolon, no comma) Since, I had an extra (star)* character in my cron entry earlier by typo error, caused cron not to send emails.
thank you everyone for your guidance.
With best regards. -- *Satish MV* M.Sc, PGDCA, UGC-NET, Librarian - Govt. Engineering College Opp. Dairy Circle, B.M.Road, Hassan 573 201 Karnataka, INDIA Mobile: +91 9449765737 Personal Email: lis4satish@gmail.com <mailto:lis4satish@gmail.com> College Website: www. <http://www.git.edu/>gechassan.ac.in <http://gechassan.ac.in/> Library OPAC: http://library.gechassan.ac.in <http://library.gechassan.ac.in/> Library Portal : https://librarygechassan.wixsite.com/library
participants (5)
-
Alvaro Cornejo -
Barton Chittenden -
Caroline Cyr-La-Rose -
Katrin Fischer -
SATISH