Sourcing file from parent directory bash

"Debian 9 64x - LXDE"

I try to source a file from my parent directory:

#!/bin/bash
#source.bash
 . ../links.bash

but i get "file not found".
I tried . "../links.bash" and . '../links.bash' . I got on all methods the same result.
If i use the absolute path it works, but i don't want to use an absolute path.

How are you calling/executing the source.bash script and from what directory?

./install.bash gets manual executed in a lxterminal window.

install.bash calls the source.bash with follow line: xterm -e "./scripts/source.bash"

source.bash gets executet in a new xterm terminal window.

After that, the . "../links.bash" gets called in the source.bash. I see "path not found" in the xterm window.

This is the absolute path directory:

install.bash is run from /home/username , where xterm is called from as well, executing ./scripts/source.bash , pwd still pointing at /home/username . So ../links will be looked for in /home , where it, of course, does not reside.

This "mess" shows again, that it may prove use- and helpful to - at least consider to - use absolute paths in script systems.

1 Like

Solved, Thank you!