If you tried, I don't think you could be more vague.
Based on such limited information the best I could suggest is that you didn't
export one or more variables from wherever you are trying to run
filename.sh from (
sh filename.sh - not an issue when you source (with
.) filename.sh).
Please try to be more descriptive than saying "It does not work".
Running it "sh ..." will run the script in a new sub-shell (sh - or whatever that point to (bash, ksh, dash, etc.)). Running it with
. will source (effectively load) it into the current shell's environment.