0

I have one shell script which is using a config file. I added the following code to use config file.

source abc.config

When I ran this shell script manually it is working fine. However, when I make this shell script as a background process using no hup, it gives me following error.

line 19: source: abc.config: file not found

I debugged the shell script using

bash -x shell_script.sh

In debugging it is taking config values properly and shell script worked.

This shell script was running fine a few days ago, but suddenly it started to give errors like this. Also the same script is running fine on another environment.

To run this shell script properly we have to give the full path of config file in source statement. But that is not correct way, since config file and shell scripts both are in same folder and for source syntax we have to give config file name only.

How can I fix this issue?

P.S : Currently, I have added path of config file as follows

source ${path}/abc.config

But I want to source a config file without path of it.

Vidya
  • 1
  • 3

1 Answers1

0

You may try "source ./abc.config" just to make sure is looking into the same folder.

--Or, depending of the complexity of executing mode/environment--

before sourcing you may detect the folder the script is running into, store that into a variable and use it as a prefix to your abc.config like

DIRN=`dirname $0`
source $DIRN/abc.config
tethis
  • 11
  • 3
  • thanks for quick reply, I am following that solution only but I want to use only config file name with source command. I checked .profile .bashrc to find some clue. but didn't get any. – Vidya Oct 13 '16 at 07:17