OpenOffice MailMerge using CLI

March 26th, 2008

“Mail merge” is a term that covers form letters (both paper and email), postcards, address labels, envelopes–any single document that you wish to send to a lot of different people. Once you have a database of contacts you can use this to automate all kinds of tasks, such as sending reminders to customers with overdue invoices, product announcements, Christmas cards, and what have you.

While working on some project i wanted to generate openoffice documents filling data like customer name automatically. Ideally this would ran on webserver and send .odt document as attachement.

PyUNO python framework is extremely powerfull, but work like “COM” in windows and would require running openoffice which is suboptimal on webserver. after searching a bit i found alternative - OOoPy which doesnt require openoffice to be installed on system.

After short playing i come up with odtcli.py python script which enable to assign values in openoffice document via command line - odtcli.py

odtcli requires OOoPy installed. You can download source rpm here - OOoPy source rpm.

Installation instructions:

1) build and install OOoPy rpm

2) download odtcli.py script andrun chmod a+rx odtcli.py

Usage instructions:

Lets say you want to set customer last name in odt document.

1) Locate in document place where you want customer lastname to be shown.

2) In openoffice menu choose “Insert” -> “Fields” -> “Other”

3) In dialog window choose “Variables” tab

4) Choose “Set Variable” option on left side, and at the bottom of dialog enter “customerlastname” as Name, some default value and “Text” as format and hit “Insert” button. Screenshot - Variable Field Creation

5) If this variable shows up more than once in document, for next occurrence use “Show Variable” instead of “Set Variable”

6) Save this document as “form-template.odt”. example here form-template.odt

7) Check that variable is properly created by running

# odtcli.py /tmp/form-template.odt
Variable : customerlastname = Customer

8) now lets say you want to create from template form for customer Mustermann

odtcli.py -s"customerlastname=Mustermann" /tmp/form-template.odt /tmp/form-muste\
rmann.odt

9) check that variable set properly

odtcli.py -l /tmp/form-mustermann.odt
Variable : customerlastname = Mustermann

10) open /tmp/form-mustermann.odt in oowriter and enjoy ;-)

odtcli.py usage

Usage: odtcli.py [OPTIONS] inputfile [outputfile]
 Options:
 -h, --help                    print this help
 -s, --set-var='name=value'    set value of variable
 -l, --list-vars               print variable names and values
Example: set values customerlastname to Mustermann and
     customerfirstname to Hans using template from customer-data.odt
 python odtcli.py --set-var="customerlastname=Mustermann" \
                  --set-var="customerfirstname=Hans" \
                  customer-data.odt /tmp/customer-566.odt

Monitor Hotplug with Xrand 1.2 - Xinerama replacement

March 19th, 2008

On my notebook i’ve used to have init script which would enable/disable Xinerama extension depending if second display connected or by modifying /etc/X11/xorg.conf. This would require X restart in order to pick up the changes.

Xrandr is used to set the size, orientation and/or reflection of the outputs for a screen. Even more importantly since Xrandr v 1.2 it detects hotplugged monitors, can enable/disable them and reconfigure X “on the fly”. Xrandr can not only discover connected display on the fly, it can also put display in xinerama like mode with 2 mointors sharing same display.

To see what is connected to system run xrandr.

On my laptop primary display called LVDS and external monitor called VGA.

To enable second monitor in xenarama like mode( note that there are also right-of,below, below)

xrandr –output LVDS –left-of VGA –auto.

Or disable second monitor

xrandr –output VGA –off

And all of this online!

References:

Xorg Xrandr v1.2 on thinkwiki

Encripted home with LUKS on Fedora 7

June 8th, 2007

On my Fedora 7 Laptop i have separate logical volume for /home
To have it encrypted

  • Backup /home
  • Unmount /home
  • format logical volume as LUKS partition with (replace <lvname> with name of you logical volume reserved for “home”): 

cryptsetup --verbose --verify-passphrase luksFormat  /dev/mapper/<lvname>
  • You will be asked for password
  • Create mapping between logial volume and luks partion
cryptsetup luksOpen /dev/mapper/<lvname> crypthome
  • You will be asked for password
  • create /etc/crypttab file with following contents (replace <lvname> with name of you logical volume reserved for “home”):
crypthome /dev/mapper/<lvname>
  • format crypthome
mkfs.ext3 /dev/mapper/crypthome
  • edit fstab and replace <lvname> with crypthome
  • test if you can mount partition
mount /home
  • reboot
  • You should be asked during boot for LUKS password for cryphome partition

Rising Free Groupware Star

March 31st, 2006

Everybody welcome “OpenSource Groupware Which Doesnt SUCK!” - Zimbra.

After spending some time looking on it i cant say what i dont like.
It certainly does make your standalone email client look bad.
Based on Ajax it delivers really polished WebUI.
Usability rox. Feauture  rich.

Check out flash demo and hosted demo on their web site, and it will leave you amazed!