#!/local/bin/perl5 ############################################################################## # dir.pl Version 1.0 # # COPYRIGHT NOTICE # # Copyright 1997 Wolfgang Wiese All Rights Reserved. # # EMail: xwolf@xwolf.com # # URL : http://www.xwolf.com # # # # dir.pl may be used and modified free of charge by anyone so long as # # this copyright notice and the comments above remain intact. By using this # # code you agree to indemnify Wolfgang Wiese from any liability that # # might arise from it's use. # # # # Selling the code for this program without prior written consent is # # expressly forbidden. In other words, please ask first before you try and # # make money off of my program. # # # # Obtain permission before redistributing this software over the Internet or # # in any other medium. In all cases copyright and header must remain intact.# ############################################################################## $rekursiv=1; @startdir="/home/rzsunhome/unrz/unrzc9/public_html/xwolf"; &GetDirEntries; print "Verzeichnisse:\n"; for ($i=0;$i<=$#startdir; $i++) { print "\t$startdir[$i]\n"; } exit(0); ##################################################################### sub GetDirEntries { $i=0; while ($startdir[$i]) { @direct=""; @direct=&Getdir($startdir[$i]); if (length($direct[0]) > 0) { foreach $datei (@direct) { $vollname=$startdir[$i]."/".$datei; $rights=&GetRights($vollname); print " $rights $vollname \n"; if ($rekursiv) { if ((-d $vollname) && (!(-l $vollname)) && ($datei ne '..') && ($datei ne '.') && (-x $vollname)) { push(@startdir,$vollname); } } } } $i++; } } sub Getdir { local($verzeichnissname)=@_; local(@dirent); if (-d $verzeichnissname) { if (!(-r $verzeichnissname)) {return "";} if (-l $verzeichnissname) {return "";} opendir(DH,$verzeichnissname) || die("Kann $verzeichnissname nicht oeffnen!"); @dirent = sort grep(!/^\./, readdir(DH)); closedir DH; return @dirent; } else { return ""; } } sub GetRights { local($fullname)=@_; if (-l $fullname) { if (-r $fullname) { if (-w $fullname) { if (-x $fullname) { return "lrwx"; } else {return "lrw-";} } else { if (-x $fullname) { return "lr-x";} else {return "lr--";} } } else { if (-w $fullname) { if (-x $fullname) { return "l-wx"; } else {print "l-w-";} } else { if (-x $fullname) { return "l--x";} else {return "l---";} } } } elsif (-d $fullname) { if (-r $fullname) { if (-w $fullname) { if (-x $fullname) { return "drwx"; } else {return "drw-";} } else { if (-x $fullname) { return "dr-x";} else {return "dr--";} } } else { if (-w $fullname) { if (-x $fullname) { return "d-wx"; } else {return "d-w-";} } else { if (-x $fullname) { return "d--x";} else {return "d---";} } } } else { #Datei if (-r $fullname) { if (-w $fullname) { if (-x $fullname) { return "-rwx"; } else {return "-rw-";} } else { if (-x $fullname) { return "-r-x";} else {return "-r--";} } } else { if (-w $fullname) { if (-x $fullname) { return "--wx"; } else {return "--w-";} } else { if (-x $fullname) { return "---x";} else {return "----";} } } } }