0

I'm having issues using oowriter to convert a doc to a pdf using php exec(). The line i'm running below works fine in CLI, just not in php using exec().

$stdin = "/usr/bin/oowriter --headless --convert-to pdf -outdir /var/data/uploads/ /var/data/uploads/lorem.docx";

exec($stdin,$stdout,$return_int);

$stdout returns an empty Array and $return_int returns 0.

I've searched around and the only possible solution I could find was adding the path to oowriter (which you can see i have done). Is there a permissions issue running this command as the apache user? There are a few posts on exec() not working in general, but I can successfully run commands for imagemagick using this method. Therefore it seems to me that this an application specific configuration issue with openoffice.

Appears to be a duplicate of the following, but no answers have been posted:

unable to run oowriter as web user

FYI I'm using CentOS V6.1 and PHP v5.3.3. Thanks.

Community
  • 1
  • 1
leejmurphy
  • 994
  • 3
  • 17
  • 28
  • Sounds like a permission issue. Who is running `exec()` and under what permissions? – BudwiseЯ Oct 14 '12 at 22:35
  • @budwiser I haven't specified any user so I can only assume the apache user is running exec() with any default permissions – leejmurphy Oct 14 '12 at 22:37
  • Try to `chmod 777 /var/data/uploads/ -R` (for debugging purposes) just for once to see if we are dealing with user rights. – BudwiseЯ Oct 14 '12 at 22:41
  • @budwiser `/var/data/uploads` is already set to 777 and FYI I can successfully execute imagemagick commands to files within this directory using exec() and apache user – leejmurphy Oct 14 '12 at 22:59
  • 1
    To test this out it is possible to sudo using apache to test the command - `sudo apache command`. Also - you can sudo in exec : `exec('echo 'password' | sudo -S leemurphy comand');` That should mean you can run the command as root (to test) - then you could try setting it up on a normal user (create a user called 'runoffice') – Boz Oct 21 '12 at 09:59

0 Answers0