user1538560 user1538560 - 1 year ago 83
Python Question

start openoffice process with python to use with pyuno using subprocess

I use this command to start openoffice:

soffice --accept="socket,host=localhost,port=8100;urp;StarOffice.Service" --headless --nofirststartwizard

The following command will ensure that openoffice is accepting connections on port 8100:

netstat -nap | grep office


tcp 0 0* LISTEN 2467/soffice.bin

Python script to start openoffice process:

command = [
subprocess.Popen(command, shell=True)

For some reason, the netstat command outputs nothing when i try to start openoffice with this python script. the process is there, but it does not accept connections.
What am i doing wrong ?

Answer Source

From the documentation:

On Unix with shell=True, the shell defaults to /bin/sh. If args is a string, the string specifies the command to execute through the shell.

If args is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell itself.

Here, you should just remove shell=True to pass the arguments to soffice instead of passing the arguments to the shell:


To use shell=True, you need to build all arguments into a single command (arguments would need to be escaped of course):

subprocess.Popen(command.join(' '), shell=True)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download