Bug 129713 - soffice --cat option doesn't output document text contents when there is another instance running
Summary: soffice --cat option doesn't output document text contents when there is anot...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
6.3.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:24.2.0
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-31 17:50 UTC by Brad
Modified: 2023-08-02 06:43 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
SS of command output. (86.76 KB, image/png)
2020-01-02 14:45 UTC, Brad
Details
Sample ODT file that doesn't --cat output (8.99 KB, application/vnd.oasis.opendocument.text)
2020-01-02 14:47 UTC, Brad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Brad 2019-12-31 17:50:38 UTC
Hi,

I'm using LibreOffice 6.3.3.2 a64200df03143b798afd1ec74a12ab50359878ed on Win10.

The --cat option of soffice.exe doesn't output the text contents of the files included on the command line as described.

>    --cat               Dump text content of the following files to console

For example command below doesn't output the text of any of ODT files I've tried the command with to the console as expected.


"%ProgramFiles%\LibreOffice\program\soffice.exe" --cat "any-odt-file.odt"
Comment 1 himajin100000 2019-12-31 20:32:32 UTC
What happens if you use soffice.com instead of soffice.exe ?
Comment 2 Brad 2019-12-31 20:45:29 UTC
I get the exact same behavior with soffice.com
Comment 3 Mike Kaganski 2019-12-31 21:48:57 UTC
Could you please attach a sample ODT file you tried with, and also a screenshot of the command and (missing) result? Thanks.
Comment 4 Brad 2020-01-02 14:45:37 UTC
Created attachment 156902 [details]
SS of command output.

Attached is the SS of command output.
Comment 5 Brad 2020-01-02 14:47:03 UTC
Created attachment 156903 [details]
Sample ODT file that doesn't --cat output
Comment 6 Brad 2020-01-02 14:48:25 UTC
Attached are the requested SS of the command output and the sample ODT file used.
Comment 7 Mike Kaganski 2020-01-02 15:25:24 UTC
(In reply to Brad from comment #6)

Thanks!

1. As mentioned in comment 1, the command like should start with

> "C:\Program Files\LibreOffice\program\soffice.com"

or simply

> "C:\Program Files\LibreOffice\program\soffice"

That is because .com is console-mode application; .exe is GUI application.

2. When you have another LibreOffice instance running, all following LibreOffice instances don't do anything themselves, but just pass their command to the first running instance. That means, in thi case, that the other program will receive the --cat command - and try to output the result to (absent) console; while this console will not receive anything.

Possibly there should be passing of the --cat and the like back to the caller ... Anyway, please test without other LibreOffice instances running (including quickstart if enabled).
Comment 8 Brad 2020-01-02 16:03:57 UTC
Using the com command ("C:\Program Files\LibreOffice\program\soffice.com" --cat test-cat.odt) without any LibreOffice instances running does produce the output expected. However there is no output when there is any instance running due to the reasons you mention in part 2.

Is there anyway to use this command with an instance running without a bit of programming? I would argue that it's a big limitation and makes the commands usefulness questionable.

I would like to use the command for git revisions so it would be necessary for the command to still work on open documents.

Thanks for your time!
Comment 9 Mike Kaganski 2020-01-02 16:25:24 UTC
(In reply to Brad from comment #8)
> Is there anyway to use this command with an instance running without a bit
> of programming?

Yes: you may use a different (e.g., temporary) user profile [1] for the task, and that would create a separate process which will not offload its task to the already running instance: see -env:UserInstallation sample in help [2]. Note that, although you may use empty temp directory each time for the task, it will create significant overhead because of the need to initialize new profile; so better create a dedicated profile once, and then reuse it.

> I would argue that it's a big limitation and makes the
> commands usefulness questionable.

... which is why I didn't close it - see first sentence of last paragraph of comment 7.

[1] https://wiki.documentfoundation.org/UserProfile
[2] https://help.libreoffice.org/latest/en-US/text/shared/guide/start_parameters.html
Comment 10 Stephan Bergmann 2020-01-06 10:41:54 UTC
(In reply to Mike Kaganski from comment #7)
> Possibly there should be passing of the --cat and the like back to the
> caller

Yes, that's apparently missing in <https://gerrit.libreoffice.org/plugins/gitiles/core/+/3d318e6cf4a183e14a043840b9990958c7527536%5E!/> "fdo#70625 Add --cat parameter to make git diffs pretty".
Comment 11 Moritz Duge (allotropia) (a.k.a. kolAflash) 2023-03-24 12:01:40 UTC
WORKAROUNDS

Either use another tool like:
  odt2txt
  unoconv --format=txt --stdout


Or for your Git config (for diffing ODF files):

[diff "odf"]
	textconv = "bash -c 'td=\"$(mktemp -d)/\"; loffice --convert-to txt --outdir \"${td}\" \"${0}\" || true; cat \"${td}\"*; rm -Iv \"${td}\"*; rmdir -v \"${td}\"'"
	# NOTE: The -I for rm is important for safety reasons. DONT REMOVE THE -I!!!
Comment 12 Matt K 2023-07-26 00:45:27 UTC
Fix is tracked in https://gerrit.libreoffice.org/c/core/+/154909
Comment 13 Commit Notification 2023-08-02 06:25:51 UTC
Matt K committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/efae7b4a1f7248b01e8cd95577c09d772cfe5709

tdf#129713 Output message when using "--cat" with other LO instances running

It will be available in 24.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Matt K 2023-08-02 06:35:06 UTC
(In reply to Commit Notification from comment #13)
> Matt K committed a patch related to this issue.

This patch just adds an error message so people can see why --cat fails if another LO instance is running.

Resetting to NEW for anyone who wants to try to handle dumping cat content to console via the IPC pipe.  Either the console has to be shared somehow, or the text content has to be marshalled back to the pipe somehow, it seems, which looks like a non-trivial amount of work.