1

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!!

RobBob
  • 11
  • 4

1 Answers1

2

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.

Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
  • But could you please add printenv just to check it? – Igor Chubin Jan 27 '14 at 08:20
  • Could you please start the script with `bash -x`? – Igor Chubin Jan 27 '14 at 08:29
  • @user3194248 - What Igor asks is that you add `printenv` as first line in your script, just before `if`. You could try this: `printenv | grep SOME_LIB; if ...` Then show the output. No need to display all the other env-variables. – grebneke Jan 27 '14 at 08:29