Interesting pieces of code
Posted: Monday 26th September 2016 12:38pm
Ok, I know some of you have some piece of code or ideas that is/was really a problem solver. Let's see some!
CREATING EDITABLE DOCUMENTS FOR AN OFFICE
Problem: The office produces some huge reports using LibreOffice. To much text to type!
Solution: These reports are water sample analysis.
1) The lab feeds the results into a postgresql database.
2) When finished the work on the water sample by the lab, an office software alerts its user.
3) This software has a odt report template, which is copied to another directory for edition and uncompressed there.
4) All the data is in the content.xml file. So, we could use a script to edit some placeholders we have in our template. Here is an example:
5) After editing, we can compress the files again, rename it as ".odt" e save it to a FTP server. Here is an example of the FTP transaction:
Once in the FTP server, the file is available to the customer.
CREATING EDITABLE DOCUMENTS FOR AN OFFICE
Problem: The office produces some huge reports using LibreOffice. To much text to type!
Solution: These reports are water sample analysis.
1) The lab feeds the results into a postgresql database.
2) When finished the work on the water sample by the lab, an office software alerts its user.
3) This software has a odt report template, which is copied to another directory for edition and uncompressed there.
4) All the data is in the content.xml file. So, we could use a script to edit some placeholders we have in our template. Here is an example:
Code: Select all
#!/bin/bash
cd "$1"
sed -i "s~$2~$3~" content.xml
Code: Select all
#!/bin/bash
ftp -n <<EOF
open ftp://IP
user name password
put $1
EOF