Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to findout root symlink directory?

Status
Not open for further replies.

ramana35

Technical User
Apr 23, 2012
14
HK
HI,

Thanks for looking at this.

I have a directory, which is a symlink

ex?ls -ld temp --> temporg2
ls -ld temporg2 --> temp_org

I would like to set temp_org to my final name based on temp.

Thanks in advance.
 
use [file readlink name]

_________________
Bob Rashkin
 
Thanks Bond,

It is only giving one level.

if there are 2 levels of links or 3 levels of links, i want the one which is very origin.
ex:
a->b
b->c
c->d

set var [file readlink $input] giving b when i pass input as a.
 
if it is perl i can use below code

while (-l $input) {
$input = readlink($input)
}

then it will go till it doesn't find symlink.

But i am not sure how to do it in TCL.

please let me now if any of you have clues.
 
Hi

Not much bigger theory neither in Tcl :
Code:
[b]while[/b] [teal]{[/teal][teal][[/teal][b]file[/b] type [navy]$input[/navy][teal]]==[/teal][green][i]"link"[/i][/green][teal]}[/teal] [teal]{[/teal]
  [b]set[/b] input [teal][[/teal][b]file[/b] readlink [navy]$input[/navy][teal]][/teal]
[teal]}[/teal]

Feherke.
[link feherke.github.com/][/url]
 
Amazing, this is what I wanted.
thanks a ton Feherke.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top