Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using unoconv to convert documents to PDF via a php script. When I call the script from the browser, the script outputs the following (and fails):

array(11) {
  [0]=>
  string(48) "Office base location: /usr/lib64/openoffice.org3"
  [1]=>
  string(69) "Office binary location: /usr/lib64/openoffice.org3/basis-link/program"
  [2]=>
  string(28) "Existing listener not found."
  [3]=>
  string(80) "Launching our own listener using /usr/lib64/openoffice.org3/program/soffice.bin."
  [4]=>
  string(56) "OpenOffice.org listener successfully started. (pid=4157)"
  [5]=>
  string(55) "Selected output format: Portable Document Format [.pdf]"
  [6]=>
  string(41) "Selected office filter: writer_pdf_Export"
  [7]=>
  string(22) "Used doctype: document"
  [8]=>
  string(45) "Output file: ../app/storage/tmp/phpTvmZfm.pdf"
  [9]=>
  string(36) "Terminating OpenOffice.org instance."
  [10]=>
  string(44) "Waiting for OpenOffice.org instance to exit."
}
int(5)

You can see that it appears to be working, until we see int(5) which indicates the script exited with status 5. Also the pdf file never gets written.

If I execute the exact same script from the command line I get the following:

# php test.php
Verbosity set to level 2
Connection type: socket,host=localhost,port=2002;urp;StarOffice.ComponentContext
Input file: ../app/storage/tmp/phpTvmZfm
array(11) {
  [0]=>
  string(48) "Office base location: /usr/lib64/openoffice.org3"
  [1]=>
  string(69) "Office binary location: /usr/lib64/openoffice.org3/basis-link/program"
  [2]=>
  string(28) "Existing listener not found."
  [3]=>
  string(80) "Launching our own listener using /usr/lib64/openoffice.org3/program/soffice.bin."
  [4]=>
  string(56) "OpenOffice.org listener successfully started. (pid=4094)"
  [5]=>
  string(55) "Selected output format: Portable Document Format [.pdf]"
  [6]=>
  string(41) "Selected office filter: writer_pdf_Export"
  [7]=>
  string(22) "Used doctype: document"
  [8]=>
  string(45) "Output file: ../app/storage/tmp/phpTvmZfm.pdf"
  [9]=>
  string(36) "Terminating OpenOffice.org instance."
  [10]=>
  string(44) "Waiting for OpenOffice.org instance to exit."
}
int(0)

It works fine with a status code 0 and the file correctly gets written. Here is the contents of my test script:

test.php

exec("/usr/bin/unoconv -vvv ../app/storage/tmp/phpTvmZfm", $output, $return_var);

var_dump($output);
var_dump($return_var);

I can also verify that when I call the script from the browser, the correct user is is calling the script and has read/write privileges from the ../app/storage/tmp folder.

Why is my file not getting created when test.php is called from the browser? What else can I do to troubleshoot this?

Edit

I also forgot to mention my server is running centos 5.8 and WHM/cPanel. It's been configured to use DSO as the php handler.

share|improve this question
    
try having your script write a small text file to the same directory to check that it definitely isn't a write permissions issue. –  Loopo Mar 3 at 21:29
    
I tried the following exec("touch test.txt"); and it worked fine. It looks like openoffice is throwing an exception at some point. But I'm not sure why it's failing when called via the broswer and not on the command line. –  greatwitenorth Mar 3 at 22:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.