Bash - importing text into libre office

I need another way to import into libre office calc without using a temporary file. FYI, the new command option sets up a format that can be read by it.

scanvirus -vl s > /tmp/scanvirus_temp.txt;libreoffice --calc /tmp/scanvirus_temp.txt


This sounds more like a libreoffice question. Can one specify a file in a libreoffice command to be standard input? When yes, then one can of course pipe the output of the first program into openoffice.

I did a short glance through man libreoffice, but standard input is mentioned nowhere.

For days, I looked up everything I could find on pipes, input/output redirection, and libre office calc. Nothing works!

Also, libre office will not accept anything but this format. I need a method of input redirection that will that make libre office calc think the text output of scanvirus is an actual text file. ??

So far I as well have not found any way to enter data via pipe or I/O-redirection into LibreOffice.

Could you provide more details on why you don’t want/cannot use the solution you presented in your post #1 (usage of a temporary file)?

LibreOffice Calc will work with .csv-files as well.

I do not use scanvirus so I don’t know if it can produce a .csv-file. If you could provide a brief example of what the scanvirus output looks like it might be possible to find a way to convert that into .csv.

Wise man say, “Why climb a mountain? Because it’s there!” :slight_smile:
Maybe they will fix libre office later. Even though I have a text configuration file for scanvirus, I made a GUI editor, because I wanted to learn if I could do it. :wink:

CSV files, i’ll have to look into. I’ve fixed the scanvirus-gui code to include the text line version. It works fine, but the title lines corrupt the formatting in libreoffic calc. So, I had to remove them. I made a workaround that functions well. Still needs more testing.

I have no idea what you are talking about, but can we consider this thread as “closed”?

Doing coding just for the sake of learning coding is a good thing. Can’t get much simple then that… :wink:

Yes, I got my answer. There is no known way of piping or redirecting input for libre office calc.

Topic Closed.

@lord_valarian use perl

The app is in bash. Rewriting it perl is impractical. It’s over 2000 lines.

Do mean write perl code in bash? Use an external file?

@lord_valarian calling an import script could be an option, there are many perl modules you could use to perform an import/export.

calling an import script could be an option, there are many perl modules you could use to perform an import/export.

I’m new to perl and have never used it. Where do I start? This code is what currently works. So, bash can run perl modules? A perl module that will work similar to this. One that is built into perl.

               tmp_file=$(mktemp -q /tmp/scanlog.XXXXXXXXXXXXXXXX || exit 1)
               #echo $tmp_file
               scanvirus -vl i > "$tmp_file"
               libreoffice --calc "$tmp_file"
               rm $tmp_file

I would say bash can not run perl modules but that is just naming, it can run perl scripts just like you are running scripts from the command line prompt.

The simplest way to run a script is just to put the filename of that script in you bash script. Use the filename with an absolute path for sure if it is not in the PATH, but anyhow this is often good to do.

If you want to capture the output of the script that is also possible:


echo $OUT

I’ll do some reading into perl scripts. Thanks for the info…

Perhaps, I am missing the question but you can’t import a text file into librecalc (spreadsheet) app w/o some kind of cell formatting info, I would think. Else, you would just get a spreadsheet with a text file in one cell.

The above code imports data into libre office calc:

04/12/2023 OS_Type Virus_Status Scan_Folder Scan_Time Command_Options Time_Stamp Date_Stamp Partition_Log/Excluded_Scan_Folders
01/11/2023 linux clean / 01h:49m:50s cu 11:11:00pm 2023-01-11 {.snapshots|var|usr/local|tmp|srv|root|opt|home|boot/grub2/x86_64-efi|boot/grub2/i386-pc|boot/efi|dev|proc|sys|run}
01/25/2023 linux clean / 01h:52m:32s cu 10:31:18pm 2023-01-25 {.snapshots|var|usr/local|tmp|srv|root|opt|home|boot/grub2/x86_64-efi|boot/grub2/i386-pc|boot/efi|dev|proc|sys|run}
02/01/2023 linux clean / 01h:53m:46s cu 11:13:09pm 2023-02-01 {.snapshots|var|usr/local|tmp|srv|root|opt|home|boot/grub2/x86_64-efi|boot/grub2/i386-pc|boot/efi|dev|proc|sys|run}
02/08/2023 linux clean / 01h:56m:45s cu 10:57:43pm 2023-02-08 {.snapshots|var|usr/local|tmp|srv|root|opt|home|boot/grub2/x86_64-efi|boot/grub2/i386-pc|boot/efi|dev|proc|sys|run}

With some extra code, the above format comes out neat and clean on import.

But, I’m using spaces (scanvirus default scanlog format) as the separator between cell data. This is bad for filenames in linux or windows. If change the defaults to ‘|’ or other characters not used in filenames, this should solve the problem. Any user of scanvirus, can change the default log format to better be imported from libre office calc.

Automated fixing of the log spaces is hard to code during importing to LOC. So, I just manually fixed my logs.