0

I have a property file say mypropety.properties where i have set multiple key value pairs.

I load properties to the current session running $. myproperty.properties command.

Now when I run script using $. myscript.sh it loads all variable values from session and works fine. However in my use case I need to run the command using sh myscript.sh command and when I run it this way it doesn't replace variable values in the script and fails.

Any idea how to do variable substitution when running a script with sh command?

Ravi Yadav
  • 13
  • 1
  • 7

1 Answers1

0

Bash looks for the variable BASH_ENV in the environment and if present expands and reads the file.

sh -c "BASH_ENV=myproperty.properties myscript.sh"
strobelight
  • 267
  • 2
  • 7