1

I installed libreoffice-headless and can convert documents when logged on as root. I then tried doing so as another user, and it didn't show an error, but didn't convert the file. I then found that if I get rid of the HOME=/tmp/ayb, it works with the other user. Doesn't HOME=/tmp/ayb just allow files to default to this directory if not specified? (Sorry, I tried to search "Linux HOME", but as you probably expect, received a bunch of non-relevant results). If not, what is the purpose of specifying HOME? Why does setting HOME prevent it from converting on non-root users? Note that /tmp and /tmp/ayb or both 0777. Thank you

[root@desktop ~]# yum install libreoffice-headless
[root@desktop ~]# yum install libreoffice-writer
[root@desktop ~]# ls -l
total 48
-rwxrwxrwx. 1 NotionCommotion NotionCommotion 48128 Jul 30 02:38 document_34.doc
[root@desktop ~]# HOME=/tmp/ayb; /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
convert /tmp/ayb/document_34.doc -> /tmp/ayb/document_34.pdf using writer_pdf_Export
[root@desktop ~]# rm d*.pdf
rm: remove regular file `document_34.pdf'? y
[root@desktop ~]# /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
convert /tmp/ayb/document_34.doc -> /tmp/ayb/document_34.pdf using writer_pdf_Export
[root@desktop ~]# rm d*.pdf
rm: remove regular file `document_34.pdf'? y
[root@desktop ~]# su NotionCommotion
sh-4.1$ HOME=/tmp/ayb; /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
sh-4.1$ rm d*.pdf
rm: cannot remove `d*.pdf': No such file or directory
sh-4.1$ /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
sh-4.1$ rm d*.pdf
rm: cannot remove `d*.pdf': No such file or directory
sh-4.1$ exit
exit
[root@desktop ~]# su NotionCommotion
sh-4.1$ /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
convert /tmp/ayb/document_34.doc -> /tmp/ayb/document_34.pdf using writer_pdf_Export
sh-4.1$ rm d*.pdf
sh-4.1$ HOME=/tmp/ayb; /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
sh-4.1$ rm d*.pdf
rm: cannot remove `d*.pdf': No such file or directory
sh-4.1$ /usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
sh-4.1$ rm d*.pdf
rm: cannot remove `d*.pdf': No such file or directory
sh-4.1$
1

I have really no idea what you are trying to do here.

  • $HOME is your user's home directory, why would you change that to run a program?

  • You are explicitly telling libreoffice to create a pdf in the directory /tmp/ayb which does not seem to be your current directory. You are then attempting to delete a pdf from your current directory and, of course, it does not exist because you have told it to place it in /tmp/ayb.

What happens if you do not change HOME or your user or anything else and just run:

$ libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc
$ ls /tmp/ayb/d*.pdf
  • I wasn't sure that $HOME changed the home directory, but was blindly told to do so some time in the past and don't recall the details. Thanks for clarification. Yes, I am explicitly specifying directories, so it is likely redundant. The purpose of showing rm d*.pdf was just to show viewers that it definitely wasn't created. If I do not change HOME, it works great. Why does changing HOME cause problems only for non-root users? – user1032531 Aug 2 '13 at 16:31
  • @user1032531 it was created exactly where you told it to be, have a look at /tmp/ayb/, it should be there. You are specifying an output directory, that is where the created file will be. Anyway, changing $HOME changes where the system will look for your personal configuration files and will wreak havoc with just about everything. Don't do it. – terdon Aug 2 '13 at 16:33
  • My end goal is to do this with PHP, and thus will run under user "apache". I just tried to run the above shell script using PHP, and it didn't convert the file. NotionCommotion had a default home but apache does not. I think that is why I previously specified HOME. – user1032531 Aug 2 '13 at 16:40
  • For instance, [root@desktop ~]# su -s /bin/sh apache -c "/usr/bin/libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc" does not convert the document. Why? Is a HOME needed? – user1032531 Aug 2 '13 at 16:43
  • Yes a HOME is needed but no for the command you are attempting. Just leave HOME alone, don't touch it :). Also, stop being root, go back to your normal user and just run libreoffice --headless -convert-to pdf --outdir /tmp/ayb /tmp/ayb/document_34.doc. That will create /tmp/ayb/document_34.pdf. That's all you need. – terdon Aug 2 '13 at 16:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.