![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash copy file contents into an existing file at a specific location | gshepherd7 | Shell Programming and Scripting | 6 | 03-11-2009 09:26 AM |
| Exit from sourced script | angad.makkar | Shell Programming and Scripting | 2 | 03-04-2009 06:35 AM |
| copy files from one location to similar location | pharos467 | UNIX for Advanced & Expert Users | 1 | 09-21-2008 01:21 PM |
| which file is sourced by bash on login (Mac OS X 10.5.3)? | Alex_Land | OS X (Apple) | 2 | 07-11-2008 11:52 PM |
| What is the file location? | Chanakya.m | Shell Programming and Scripting | 5 | 07-17-2006 01:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
The script is untouched as it migrates throught the life cycle regions with various file sub-systems, such as /common/dev, /common/test, and so on. Specific applications /app1 or /app2 will be invoked from an external scheduler using a parameter. So with in the /app1 script, they run $1/setCommonEnv.sh where $1 is /common/dev or /common/test ...
Within setCommonEnv.sh, i would like to derive which environment I am in, as well as which script or subscript. Seems very reasonable to be able to walk a call stack. |
|
|||||
|
If you are using ksh93 it can be easily done using the .sh.file builtin parameter
Code:
$ cat a.sh #!/bin/ksh93 echo "a: $PWD" . ./ksh93/b.sh $ Code:
$cat ksh93/b.sh
#!/bin/ksh93
echo "b: $PWD"
echo "b: ${.sh.file}"
echo "b: ${.sh.file##*/}"
echo "b: ${.sh.file%/*}"
$
Code:
$ ./a.sh a: /home/fpm b: /home/fpm b: /home/fpm/ksh93/b.sh b: b.sh b: /home/fpm/ksh93 $ |
|
||||
|
Exactly what I am looking for. However, the scripts are not running ksh93. I did run through a test cycle here on AIX 5.3, the results are below.
Code:
/test> cat a.sh
#!/bin/ksh93
echo "a: $0"
echo "a: $PWD"
ScriptDir=`dirname $0`
. ./sub/b.sh
/test> cat sub/b.sh
#!/bin/ksh93
echo "b: $PWD"
echo "b: ${.sh.file}"
echo "b: ${.sh.file##*/}"
echo "b: ${.sh.file%/*}"
/test> ./a.sh
a: ./a.sh
a: /test
b: /test
b:
b:
b:
/test>
|
![]() |
| Bookmarks |
| Tags |
| ksh file directory |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|