0

I have done following

#!/bin/bash

PROJDIR="//$HOST/projects"
cd $PROJDIR
newscript

exit 0

Purpose of the script is to enter in shared folder and trigger another script within it, but the script newscript doesn't work if it do not get full path. Here $HOST is machine name, projects is shared folder on my machine. Its actual path is C:\Users\vikram\HOME\share. I have shared it with advanced sharing options where we can share the folder with some different name. (Here it's projects.)

After entering in the directory and after doing pwd I get //VIKRAM/projects. Here I want its actual absolute path in any way.

I am using Windows 10 as OS and Cygwin as terminal.

1 Answer 1

0

If you want to execute your script in current directory. Add to your script this:

export PATH="$PATH:./"

Or use absolute path:

source ${PROJDIR}/newscript
or
. ${PROJDIR}/newscript
3
  • Hi spybull, thanks for answering ; but my issue is I need complete expanded path of $PROJDIR to correctly run the newscript. newscript will not work unless it knows the absolute path of projects, newscripts validates the path ; if it is not like : C:\Users\vikram\HOME\share then it will give error, see; projects is shared directory on all my networked machines, it's net share path is //$HOST/projects but on client machine actual absolute path may vary! Jan 23, 2020 at 12:50
  • so the prior script need to be such that it will find shared projects directory and then will get it's absolute path on any machine. Jan 23, 2020 at 12:56
  • 1
    you can try readlink -f ${PROJDIR}/newscript but I suspect it will just provide //$HOST/projects/newscript as it is a valid path on the machine. Please remember also that C:\Users\vikram\HOME\share is /cygdrive/C/Users/vikram/HOME/share under Cygwin
    – matzeri
    Jan 23, 2020 at 21:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.