You are not logged in.

#1 2010-01-20 16:40:16

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Open Office from command line: files with spaces

This has been annoying me for... ages... years even. It took me this long to bother looking for a solution, and now I can't find one! Not on Google, wiki, or forum search. It's got to be the newbiest question ever, yet I'm stumped.

When I want to open a file in oo from the commandline, I use this:

oo -writer myfile.odt

It works beautifully. wink

But if the filename has spaces, no matter what I try:

$ oo -writer my\ file.odt 
$ oo -writer "my file.odt"
$ oo -writer "my\ file.odt"
$ oo -writer 'my file.odt'

I get the same error. A little box saying that the file "my" does not exist, and a second one saying that "file.odt" does not exist.

How can I convince OO that, in fact, this is a single filename? It opens fine from the GUI open dialog, but I do stuff from the command line often enough that it's become a real pet peeve.

Dusty

Offline

#2 2010-01-20 16:51:21

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Open Office from command line: files with spaces

Never seen 'oo' before - if this is an alias or wrapper of your own - then, by the time you come to 'swriter' you will have two files - 'my' and 'file.odt'

I _think_ that you have to
a) call swriter directly or
b) quote your arguments before invoking swriter

[edit]
yup - I had no problems doing a

/usr/lib/openoffice/program/swriter 'my file.odt'

[/edit]

Last edited by perbh (2010-01-20 16:56:30)

Offline

#3 2010-01-20 16:59:23

derFrank
Member
Registered: 2008-04-01
Posts: 6

Re: Open Office from command line: files with spaces

That's confusing.. I've got the openoffice-base 3.1.1-2 packet from [extra] installed on my machine, but there is no binary named 'oo' in my search path (or in the packet). Instead, what I use to start OpenOffice is

soffice copy\ of\ file.doc

which works as expected.

Which vesion of OpenOffice did you install?

Offline

#4 2010-01-20 17:02:46

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Open Office from command line: files with spaces

I'll be damned... no wonder google didn't help. Now I feel either foolish, or like I'm losing my mind.

Apparently, oo is a poorly escaped bash script in my /usr/bin directory with these contents:

#!/bin/sh

export OOO_FORCE_DESKTOP=gnome
soffice $@

I don't remember writing it, although I can see why I did it, at the time. I've been using 'oo' for so long, I didn't realize it wasn't an official command.

soffice -writer my\ file.doc works just fine.

(edit: NOT A) Solution:

dusty:bin $ sudo rm oo
dusty:bin $ sudo ln -s soffice oo

Last edited by Dusty (2010-01-20 18:04:43)

Offline

#5 2010-01-20 17:05:00

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,385
Website

Re: Open Office from command line: files with spaces

Then add the "export OOO_FORCE_DESKTOP=gnome" to your /etc/profile (or even better /etc/profile.d/dusty).

Offline

#6 2010-01-20 17:06:23

ljshap
Member
From: Ossining, NY
Registered: 2008-01-23
Posts: 160

Re: Open Office from command line: files with spaces

I don't know what version of openoffice you have, but both the Quote and Escape methods worked using oowriter from the go-office package.  Maybe you just have to upgrade openoffice.


Did you try tab completion to see if that works, assuming the file starts with unique characters.


Live Free or Die !

Offline

#7 2010-01-20 17:26:51

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Open Office from command line: files with spaces

Dusty wrote:

I'll be damned... no wonder google didn't help. No I feel either foolish, or like I'm losing my mind.

Apparently, oo is a poorly escaped bash script in my /usr/bin directory with these contents:

#!/bin/sh

export OOO_FORCE_DESKTOP=gnome
soffice $@

I don't remember writing it, although I can see why I did it, at the time. I've been using 'oo' for so long, I didn't realize it wasn't an official command.

soffice -writer my\ file.doc works just fine.

Solution:

dusty:bin $ sudo rm oo
dusty:bin $ sudo ln -s soffice oo

You need

soffice "$@"

in your wrapper script. Otherwise it won't work wink.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#8 2010-01-20 17:45:52

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Open Office from command line: files with spaces

B wrote:

You need

soffice "$@"

in your wrapper script. Otherwise it won't work wink.

No kidding? :-P Everybody make fun of Dusty, he wrote a bad wrapper once and then forgot it wasn't the real program!

That doesn't make me a bad person. I mean, some people, phrakture, for instance, get hacked regularly, and can't touch type!

Dusty

Last edited by Dusty (2010-01-20 17:46:57)

Offline

#9 2010-01-20 18:01:07

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Open Office from command line: files with spaces

sudo ln -s soffice oo isn't a very good solution either.

Offline

#10 2010-01-20 18:03:36

perbh
Member
From: Republic of Texas
Registered: 2005-03-04
Posts: 765

Re: Open Office from command line: files with spaces

This should make it abundantly clear (mind you, I think it is allready ...)

#!/bin/sh
ekko() { i=1; while test $i -le $#; do echo "$i: ${!i}"; let i+=1; done; return 0; }
a="my file.odt"
ekko $a  # => 1: my
         #    2: file.odt
ekko "$a" # => 1: my file.odt

Last edited by perbh (2010-01-20 18:07:57)

Offline

#11 2010-01-20 18:04:13

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Open Office from command line: files with spaces

sudo ln -s soffice oo isn't a very good solution either.

Too true; soffice uses basename, and the symlink actually fails.

I'll just have to use soffice properly from now on. I just assumed that openoffice had graduated from their staroffice days to a more aptly named binary.

Dusty

Offline

#12 2010-01-20 21:04:24

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Open Office from command line: files with spaces

Dusty wrote:
B wrote:

You need

soffice "$@"

in your wrapper script. Otherwise it won't work wink.

No kidding? :-P Everybody make fun of Dusty, he wrote a bad wrapper once and then forgot it wasn't the real program!

That doesn't make me a bad person. I mean, some people, phrakture, for instance, get hacked regularly, and can't touch type!

Dusty

Well I was being gentle, but if you want us to make fun of you... lol

No worries though - I only know it because I used to repack OOo2 for the distro I used before, and users alerted me to this very problem.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

Board footer

Powered by FluxBB