This if statement:
if [ -n ${OSSIEHOME} ] && [ -d ${OSSIEHOME}/share/aclocal/ossie ]; then
OSSIE_AC_INCLUDE=${OSSIEHOME}/share/aclocal/ossie
else
echo "Error: Cannot find the OSSIE aclocal files. This is not expected!"
Constantly defaults to the error message. I know that OSSIEHOME
has a value because if I do echo $OSSIEHOME
from the command line I get
/usr/local/redhawk/core
And if I then hard code that path into my script it works fine. Problem is, I have a few other, much larger scripts where going through and hard coding the correct path isn't an option. What am I doing wrong?
Edit:
od -c <<<"$OSSIEHOME"
gives me this:
0000000 / u s r / l o c a l / r e d h a
0000020 w k / c o r e \n
0000030
ls -l /usr/local/redhawk/core/share/aclocal/
gives me this:
drwxr-xr-x 2 root root 4096 Jul 19 10:02 ossie
Running the script with bash -x
gives:
+ rm -f config.cache
+ '[' -e /usr/local/share/aclocal/libtool.m4 ']'
+ '[' -e /usr/share/aclocal/libtool.m4 ']'
+ /bin/cp /usr/share/aclocal/libtool.m4 acinclude.m4
+ libtoolize --force --automake
+ '[' -n ']'
+ '[' -d /share/aclocal/ossie ']'
+ echo 'Error: Cannot find the OSSIE aclocal files. This is not expected!'
Error: Cannot find the OSSIE aclocal files. This is not expected!
+ '[' -n ']'
+ aclocal -I
aclocal: error: option '-I' requires an argument
aclocal: Try '/bin/aclocal --help' for more information.
+ autoconf
+ automake --foreign --add-missing
I tried to export OSSIEHOME
to make it global (just in case) but that didn't work. I then tried to run the script at . script.sh
and source script.sh
problem is I need to run the script with sudo or it won't have the necessary permissions to work. if I do though I get the error
sudo: source: command not found
od -c <<<"$OSSIEHOME"
show you? – glenn jackman Aug 10 '17 at 15:47echo $OSSIEHOME
in the same environment as the terminal in which you are running the script? – user4556274 Aug 10 '17 at 15:48od -c <<<"$OSSIEHOME"
gives me this:
– nb12345 Aug 10 '17 at 15:490000000 / u s r / l o c a l / r e d h a 0000020 w k / c o r e \n 0000030
ls -l /usr/local/redhawk/core/share/aclocal/
? (When responding to comments, please edit your question with the additional information, rather than with another comment.) – user4556274 Aug 10 '17 at 15:53if [[ -d ${OSSIEHOME?}/share/aclocal/ossie ]]
? – DopeGhoti Aug 10 '17 at 15:54[ -n ${OSSIEHOME} ]
would return true if $OSSIEHOME was empty as you forgot to quote the variable. You forgot to quote all variables actually. – Stéphane Chazelas Aug 10 '17 at 15:55bash -x
to see what happens. – Stéphane Chazelas Aug 10 '17 at 15:56export OSSIEHOME
to make it global (just in case) but that didn't work. I then tried to run the script at. script.sh
andsource script.sh
problem is I need to run the script with sudo or it won't have the necessary permissions to work. if I do though I get the errorsudo: source: command not found
– nb12345 Aug 10 '17 at 16:18sudo
is important information not stated in your question (contrary to your earlier comment, you were not running the script in the same environment as theecho
command... unless you were runningsudo echo
). Try running assudo -E
(preserve environment of the original user). – user4556274 Aug 10 '17 at 16:34