I'm using the following exec
command:
MainFolder is the main folder inside it mainScript.sh and settings folder
mainScript.sh (Located in MainFolder) :
....
...
...
exec "../settings/helper.sh"
The file helper.sh
is located one folder before the current directory , in settings
folder
but exec
throws no such file or directory
.
Any idea how to fix this ?
CodePudding user response:
You have to declare the variable MAINFOLDER in your script mainScript.sh
MAINFOLDER=$(dirname $(readlink -f $0))
and call any script relative to $MAINFOLDER
if settings is in $MAINFOLDER
exec "${MAINFOLDER}/settings/helper.sh"
if settings is located one folder before
exec "${MAINFOLDER}/../settings/helper.sh"