Reputation: 11
I've got a .sh script and it has this "if" in it:
if [ -z "$SOME_LIB" ]; then
echo "Environment variable SOME_LIB is needed!"
exit 1
fi
Now. When I type "printenv" I can see that "SOME_LIB" has value "/usr/local/lib/python2.6 ". That path is correct. And all is good. But when I want to run that .sh file from terminal is gives me "Environment variable SOME_LIB is needed!"
What do i have to do to get it running properly?
Thank's for your help!!
Upvotes: 1
Views: 2436
Reputation: 64613
Could you add printenv
just befor the command if
in the script?
It is possible that the variable is unset in the script before.
Another option, debug the script using set -x
in it or running it using bash -x
to see what value contains the variable while checking.
Upvotes: 2