The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 07-01-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,122
b.sh
Code:
#!/bin/ksh

thisFILE="$(whence ${0})"
thisDIR="$(dirname ${thisFILE})"
PROGNAME="${0##*/}"

WhereAmI="${thisDIR}"
echo "b: <${PROGNAME}> ${WhereAmI}"
Note: this works if a.sh and b.sh reside in the same direct. If b.sh is somewhere else, it returns a.sh location (and rightfully so). Need to think about that.

Last edited by vgersh99; 07-01-2009 at 11:58 AM..
Bits Awarded / Charged to vgersh99 for this Post
Date User Comment Amount
07-01-2009 Anonymous N/A 1