CE> /usr/lib64/libreoffice/program/soffice: line 54: dirname: command not found

Run a java program that uses LibreOffice Java API to convert a doc into pdf file using a Bash script on the Linux terminal and I am getting this error. Any idea how to resolve it?

FYI, Using Eclipse I am able to run the program successfully.

But using a Bash script to run the program on the Linux terminal, I am getting this error below.

CE> /usr/lib64/libreoffice/program/soffice: line 54: dirname: command not found
CE> /usr/lib64/libreoffice/program/soffice: line 124: grep: command not found
CE> /usr/lib64/libreoffice/program/soffice: line 130: uname: command not found
CE> /usr/lib64/libreoffice/program/soffice: line 161: /home/Programs/ACS2CC_Print2PDF_Integration/oosplash: No such file or directory

Hi Eike,

This time, I used with my own user login account not the root account. Getting the same error.
Here is the content of my user login’s .bash.profile file.

Get the aliases and functions

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

User specific environment and startup programs

export PATH

export PATH=/usr/sbin:$PATH

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH

export TMP=/tmp
export TMPDIR

Eike,

FYI, I installed LibreOffice, using the root account.
Thank you again for your help.

Eddie

Eike,

grep is in /usr/bin.

in my login account’s .bash_profile, I only set the below, and still getting the same error.

export PATH=/usr/sbin:/bin:/usr/bin

Make sure your bash shell’s PATH environment variable has set /usr/bin and maybe /bin (depends on the distribution which path grep is installed to), so echo $PATH should display at least /usr/bin or maybe /usr/bin:/bin somewhere in the output.

Hi Eike,

Thanks for the feedback.

I did it as you can see below. /usr/bin is included.

[root@wcserverone# echo $PATH

/usr/lib64/qt3.3/bin:/usr/local/sbin:/usr/sbin:/usr/local/bin:/usr/bin:$PATH:/usr/lib/jvm/jdk1.8.0_92/bin:/usr/lib/jvm/jdk1.8.0_92/jre/bin:/root/bin

  1. Please don’t post comments as answers. It is not an answer to the original question.

  2. You should not run such things as root.

  3. The content containing a literal $PATH string is wrong. Check the script that is assembling that content.

  4. Check that the PATH variable is actually exported and not just local to the script that sets the variable.

Hi EiKe,

Many Thanks for your hints and suggestions.

The issue was that since I was executing my own bash script to run the java program, I had to include in that bash script, the following: /usr/bin/grep:/usr/bin:/bin:/root/bin:usr/bin on the below:

export PATH=${JAVA_HOME}/bin.

So, setting this below in my bash script, did the trick. Never updated my user login account’s .bash_profile

export PATH=${JAVA_HOME}/bin:/usr/bin/grep:/usr/bin:/bin:/root/bin:usr/bin

Note that /usr/bin/grep is the executable and thus listing it in PATH is superfluous. And usr/bin (without leading /) at the end looks odd. That adds a usr/bin search path relative to the current work directory (which may even be harmful).