Softlink directory name not working on SUN


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Softlink directory name not working on SUN
# 1  
Old 09-04-2012
Question Softlink directory name not working on SUN

I am facing a peculiar problem on SUN machine.
There is a soft link pointing to a directory. And there is a shell script inside this soft link which is trying to get the directory name from where this script is being executed.

Code:
NAME="$(cd $(dirname $0); pwd)"

I want to fetch the absolute path of the soft link from this shell script but it is returning the target directory path. On LINUX machine it is working fine.
I tried with "pwd -L" but still it is giving the target directory path.

The interpreter is set as "ksh" in the shell script:

Code:
#!/bin/ksh

If I remove this above line (#!/bin/ksh) or if I set it to "bash" then it is working fine and "pwd -L" is giving me the path of soft link and not the target directory path.
But I don't want to set the interpreter to "bash" due to some other dependencies.

So in "ksh" how can I get the absolute path of the soft link and not of the target directory?

Last edited by radoulov; 09-04-2012 at 07:17 AM..
# 2  
Old 09-04-2012
Code:
NAME=$( ls -l $0 | awk '{print $NF}' | xargs dirname)

try that.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Sun Fire 480 - devfsadm -C not working after replacing one of the boot disks

Our SunFire 480 - one of the boot disks failed. It is mirrored with VxVm. I followed the exact steps that is detailed in the veritas and sun guides (I can not post the URL since I don't have 5 posts yet.) After removing the failed disk, I ran devfsadm -C -c disk and it still shows the device... (7 Replies)
Discussion started by: jtamminen
7 Replies

2. UNIX for Dummies Questions & Answers

Softlink problem

Hi there is a file 'linkk' and i have created a softlink for it in another directory. $ pwd /home/guest/khare $ ln -s linkk /home/guest/khare/AWK/done now under AWk dir i can see that the softlink is created. $ pwd /home/guest/khare/AWK $ ls -lrt *done lrwxr-xr-x 1 khare... (2 Replies)
Discussion started by: scriptor
2 Replies

3. UNIX for Dummies Questions & Answers

Softlink Issue

Hi, We have a directory /oracle/UD1/sapdata1,since sapdata1 had no space we created a directory under /oracle/UD1/orarch/sapdata1 and soft linked /oracle/UD1/sapdata1 to /oracle/UD1/orarch/sapdata1 . Is there any way I can see if the files are being actually written to... (4 Replies)
Discussion started by: buddy1
4 Replies

4. UNIX for Dummies Questions & Answers

How to identify a link whether it is a Hardlink or Softlink

i am new to UNIX environment please tell me how to identify a link whether it is a Hardlink or Softlink ? what is the command? thank you all .......:o:o (2 Replies)
Discussion started by: sasith90
2 Replies

5. Solaris

Sound not working on Solaris 10 running on Sun Virtual Box

Hello Friends, I have installed Solaris 10 on on Sun Virtual Box. I am able to browse internet on solaris 10 thru firefox, however I am not getting sound, there is cross on the tray icon of sound. Please help with this !! Regards, Sahil (3 Replies)
Discussion started by: sahilsardana
3 Replies

6. Solaris

solaris 10- cant create softlink

bash-3.00# ln -s /lib /usr/lib ln: cannot create /usr/lib/lib: File exists bash-3.00# (4 Replies)
Discussion started by: incredible
4 Replies

7. Solaris

how to tar a directory in a sun solaris?

i have lot of directories which are needed to be transferred to a LINUX workstation. to do this i need to tar the directories. please let me know how to tar the directories in Sun Solaris. (7 Replies)
Discussion started by: mmb
7 Replies

8. UNIX for Dummies Questions & Answers

Questions on PATH env havinf softlink

I have a question regarding the PATH environment on SunOS. I am setting the PATH as - export PATH=$PATH:/bin and /bin has a softlink as lrwxrwxrwx 1 root root 9 Oct 1 2004 /bin -> ./usr/bin So, will this path will work for the bin having the softlink? Thanks for... (1 Reply)
Discussion started by: xgr3
1 Replies

9. UNIX for Dummies Questions & Answers

How to compress a directory on a Sun Solaris 5.7 ?

Hi, Is there any utility to compress an entire directory on a Sun Solaris 5.7 ? Something like "compressdir" on other flavours of Unix ? Thanks (4 Replies)
Discussion started by: sameerdes
4 Replies
Login or Register to Ask a Question