29 lines
707 B
Python
Executable file
29 lines
707 B
Python
Executable file
#! /usr/bin/python
|
|
# recursively print links, Sam K (2000)
|
|
import os,string,getopt,sys
|
|
|
|
def simplif(base,n) :
|
|
return os.path.normpath(os.path.join(base,n))
|
|
|
|
optlist, args = getopt.getopt(sys.argv[1:], "")
|
|
n=args[0]
|
|
print n
|
|
cur=os.path.abspath(".")
|
|
i=0
|
|
while i<2000 and os.path.islink(os.path.join(cur,n)) :
|
|
print "%d-level link : %s -> %s" % (i,n,os.readlink(n))
|
|
n2=simplif(os.path.dirname(n),os.readlink(n))
|
|
# print " - > %s" % n2
|
|
i=i+1
|
|
n=n2
|
|
if i>=2000 :
|
|
print "Circular links : %s / %s " % (cur,args[0])
|
|
raise "circular_link"
|
|
|
|
print "real File : %s" % n
|
|
if os.path.isfile(n) :
|
|
os.system('ls -lF '+n)
|
|
os.system("file "+n)
|
|
else :
|
|
print "Broken Link !!"
|
|
|