I am having trouble creating path reference in shell scripts.
I have 1 parent folder, which has 2 child folders.
Directory Structure =>
Parent
|
-- Child1 (contains shell script start)
|
-- Child2 (contains python files)
Now inside Child1, I have start.sh
#!/usr/bin/env bash
/usr/bin/python ../Child2/code1.py
Problem :
When I cd into Child1 and run the start.sh, it works perfectly.
But when I run start.sh from anyother directory (say /home/), the relative path reference in the shell script complains. It says No file found, and this is because it is using /home/ and using that as relative path. I have tested this by doing an echo $pwd
I have tried `$pwd' & '$cwd'. It does not help.
My aim is to have this shell script to work from anydirectory. How can I achieve this?
Looking forward to some help here. I would be happy to add more information if needed.