English
Ask Your Question
0

How to NOT connect to a running instance

asked 2012-04-04 02:51:01 +0200

jimav gravatar image

updated 2013-07-24 20:39:09 +0200

bosyber gravatar image

I want to convert files from a script using command line options, for example:

   libreoffice --headless --invisible --convert-to csv file.xls

This works only if Libre Office is not currently running interactively.

For example, if localc was run (on an unrelated document), then the above shell command silently fails to have any effect.

I suspect the command connects to the pre-existing interactive instance. How can I prevent this, forcing the command to use an independently started instance?

(or any other way to make the command work reliably, whether or not LO is already running)

edit retag flag offensive close delete

1 answer

Sort by » oldest newest most voted
3

answered 2012-04-04 20:39:39 +0200

hunteke gravatar image

updated 2012-07-14 07:55:23 +0200

This is unfortunately not directly possible thanks to Bug #37531.

The workaround is to run LibO with another profile. From that bug report then, comment 25 suggests using the not-so-well documented -env flag:

    libreoffice "-env:UserInstallation=file:///tmp/LibO_Conversion" --headless --invisible --convert-to csv file.xls

If security is a concern, note that LibO creates that directory with user-only permissions, and you can similarly tack on an rm (or the appropriate operating system variant) command:

    libreoffice [...] ; rm -rf /tmp/LibO_Conversion
edit flag offensive delete publish link more

Comments

Thanks, very useful. Small correction though, it should be:

-env:UserInstallation="file:///tmpLibO_Conversion"

bosyber ( 2013-07-24 20:21:41 +0200 )edit

Heh. It actually doesn't matter. The quotes are interpreted by the shell and are only required if there are "special characters" (e.g., spaces). They become more necessary if you want more robust behavior when interacting with unknown (user) input or variables, so using them as a matter of habit is just good practice. In this case, both methods will give LibreOffice the exact same string (with no quotes because the shell will remove them).

hunteke ( 2013-07-25 15:38:51 +0200 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2012-04-04 02:51:01 +0200

Seen: 1,837 times

Last updated: Jul 14 '12