Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
838 views
in Technique[技术] by (71.8m points)

linux - Libreoffice --headless refuses to convert unless root, won't work from PHP script

Running headless Ubuntu server 12.something.

root@server: chown www-data /my/path/ -R

root@server: chgrp www-data /my/path/ -R

root@server: chmod 755 /my/path/ -R

root@server: libreoffice --headless --convert-to pdf:writer_pdf_Export /my/path/foo.ppt --outdir /my/path

convert /my/path/foo.ppt -> /my/path/foo.pdf

Works like a charm.


root@server: sudo -i -u www-data

$libreoffice --headless --convert-to pdf:writer_pdf_Export /my/path/foo.ppt --outdir /my/path

convert /my/path/foo.ppt -> /my/path/foo.pdf
Error: Please reverify input parameters...

Damn.


root@server: sudo -i -u someotheruser

$libreoffice --headless --convert-to pdf:writer_pdf_Export /my/path/foo.ppt --outdir /my/path

convert /my/path/foo.ppt -> /my/path/foo.pdf
Error: Please reverify input parameters...

Damn.

Anyone have any idea? Trying to research this just confused me more. Is this probably a bug or some dependency quirk?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I finally found an answer to this... Add:

export HOME=/tmp &&

to the beginning, so:

export HOME=/tmp && libreoffice --headless --convert-to pdf:writer_pdf_Export /my/path/foo.ppt --outdir /my/path

That worked for me on CentOS 6.5, and as shell_exec() in PHP.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...