Gene,
It sounds like you want the script origin directory, not the current
working directory.
If so, I use this at the top of my scripts:
Command0=$(basename $0)
CommandPath=$(whence $0)
CommandPathDir=${CommandPath%/*}
[[ $Command0 == $CommandPath ]] && CommandPathDir=$PWD
The last line might be needed only if you are using an older
ksh93 which has a bug in the whence built-in command, where
if your script resided in the same dir where it was executed ($PWD),
whence would just return the script file name and not the full path.
I think David Korn added a $(.sh.foo} special variable that contains
the script origin dir, but I don't recall what it is.
Regards,
Mario DeFazio
On 8/22/2009 8:33 AM, gene golub wrote:
Hi folks
Here is my challenge. I need to run script each time in a different
directories. They hold input files. My problem is that I can not
detect directory where I currently invoke script in a script.
That's why I can not use files in a current directory as input files.
A=`pwd`
or
A=$PWD
do not produce accurately current directory.
Thank you for any suggestions.
------------------------------------------------------------------------
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users