Hi Mario, thank you for your respond.
Not exactly what I need. Let me explain again with examples. I have script in directory c:/scripts/s1 which i need to execute from different directories. I have a bunch of directories like: c:/prod/chg1 c:/prod/chg2 c:/prod/chg3 By the way, I use mks toolkit - commercial ksh NT port. I think it's not relevant to the topic but explains 'not UNIX' names in examples. I will be executing scripts s1 from directories: c:/prod/chg1, chg2 and chg3. In s1 script I will have to refer to input files which reside in a current directory of execution. At one time it will be directory chg2. Next time it could be in chg3 or any other directory which is not known to me at this time. My script should be able to pick up the current execution directory, get it into variable and parse as a part of file name into the script. When I execute your lines from different directories, they show me either $HOME directory or script home directory. Do you have remedy for this task? Thank you again for taking time and efforts to share your rich experience. Gene. Date: Sat, 22 Aug 2009 18:13:25 -0400 From: [email protected] Subject: Re: [ast-users] How to detect directory invocation in a script To: [email protected] CC: [email protected] 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
