Running shell script using .env file

You need to source the environment in the calling shell before starting the script:

source 'filename.env' && bash 'scriptname.sh'

In order to prevent polution of the environment of the calling shell you might run that in a sub shell:

(source 'filename.env' && bash 'scriptname.sh')

Leave a Comment