1

I am not able to execute this line via script properly:

export PATH=/usr/lib64/openmpi/bin:$PATH;

or writing it to a file and sourcing the file:

echo "export PATH=/usr/lib64/openmpi/bin:$$PATH" >> shrc;
source shrc;

when I lunch the openFoam Installation afterwards it tells me "command not found mpicc" only when I directly type it myself into the commandline everything works just fine.

(the script is executed using a function therefor I source the script before executing the function - mpicc is not in conflict with other variables)

(I also tried setting mpicc as alias with the complete path "/usr/lib64/openmpi/bin/mpicc" and also tried to export not only the bin directory but the direct path to mpicc to $PATH - nothing worked)

How can I run this command by script so that ./Allwmake of OpenFOAM will be able to find it?

(Using BASH, RHEL 7.6 (Maipo))

2
  • Your question is unclear.  You say you are not able to execute the line export PATH=/usr/lib64/openmpi/bin:$PATH;.  What does that mean?  Does it give an error message, or does it just leave you unable to run mpicc?  You say tried defining mpicc as alias with the complete path /usr/lib64/openmpi/bin/mpicc and that didn’t work. The obvious questions are: what happens when you just type /usr/lib64/openmpi/bin/mpicc into the shell?  What does ls -ld /usr/lib64/openmpi/bin/mpicc say? Commented Apr 23, 2019 at 1:43
  • Yes I tried both but the question was indeed unclear because I was able to run mpicc from commandline w/o the full path but still the script wasn't able to run mpicc from commandline. This could be fixed following the instruction from your answer. (Still I have no clue why it is needed to echo the export to a bashrc file to source this file afterwards instead of just directly extending the path) Commented Apr 27, 2019 at 9:16

1 Answer 1

0

Well, your second command block is flawed: that’s not the way to echo a $.  You must do either

echo "export PATH=/usr/lib64/openmpi/bin:\$PATH"

(using \$), or

echo 'export PATH=/usr/lib64/openmpi/bin:$PATH'

(using single quotes, and an unadorned $).

1
  • For some reason I thought $ is passed in bash by doubeling it (escaping) - will test and report, thanks so far Commented Apr 23, 2019 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .