Hallo,
Ik wil in een directory kijken of de files directories zijn of gewone files.
Dit gebeurd met onderstaande :
Voor sommige dirs gaat dit goed, maar meestal niet
bv voor deze dir :
drwxrwxrwx 4 Temmink root 4096 apr 5 01:55 .
drwxr-xr-x 13 root root 4096 mrt 24 01:18 ..
drwxrwxrwx 3 Temmink root 4096 apr 5 02:08 arno
drwxr-xr-x 2 root root 4096 apr 5 01:47 arno2
-rw-r--r-- 1 root root 0 mrt 30 01:34 lib.pl
-rwxr--r-- 1 root root 1349 apr 5 01:45 list.pm
-rwxrwxrwx 1 root root 137 apr 2 11:51 mp3.pl
-rwxr-xr-x 1 root root 268 mrt 24 00:22 printenv
-rwxr-xr-x 1 root root 14662 mrt 27 13:51 test1.mp3
-rwxr-xr-x 1 root root 16752 mrt 27 13:51 test2.mp3
-rw-r--r-- 1 root root 0 apr 2 23:28 test2.pl
-rwxrw-rw- 1 Temmink Temmink 0 apr 2 23:29 test3
-rw-rw-r-- 1 Temmink Temmink 7 apr 5 00:29 testarno.pl
-rwxr-xr-x 1 root root 757 mrt 24 00:22 test-cgi
-rwxr--r-- 1 Temmink root 389 apr 2 12:12 testdir.pl
-rw-r--r-- 1 root root 521 mrt 29 23:53 testmp3.pl
-rwxr-xr-x 1 root root 3601 mrt 27 13:51 test.pl
-rw-r--r-- 1 root root 5 apr 5 00:28 testroot.pl
-rw-r--r-- 1 Temmink Temmink 8350342 mrt 29 23:27 totalScience.mp3
krijg ik deze output.
Contents of the current directory:
test1.mp3
printenv
test-cgi
test2.mp3
test.pl file 0
totalScience.mp3
testmp3.pl
testdir.pl file 389
lib.pl file 0
mp3.pl file 158
list.pm file 2079
arno
arno2
test2.pl
test3
testroot.pl file 0
testarno.pl file 9
Heeft iemand een idee waarom niet alle files als file worden gezien, en ook directories niet? Aan de rechten kan het volgens mij niet liggen.
Ik wil in een directory kijken of de files directories zijn of gewone files.
Dit gebeurd met onderstaande :
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| {
print "Contents of the current directory:\n";
opendir DH, "../" or die "Could not open mp3";
while ($_ = readdir(DH) )
{
next if $_ eq "." or $_ eq "..";
print $_;
print "\tdir" if( -d $_ );
print "\tfile" if -f _;
print "\t";
print -s _ if -r and -f _;
print "\n";
}
closedir(DH);
} |
Voor sommige dirs gaat dit goed, maar meestal niet
bv voor deze dir :
drwxrwxrwx 4 Temmink root 4096 apr 5 01:55 .
drwxr-xr-x 13 root root 4096 mrt 24 01:18 ..
drwxrwxrwx 3 Temmink root 4096 apr 5 02:08 arno
drwxr-xr-x 2 root root 4096 apr 5 01:47 arno2
-rw-r--r-- 1 root root 0 mrt 30 01:34 lib.pl
-rwxr--r-- 1 root root 1349 apr 5 01:45 list.pm
-rwxrwxrwx 1 root root 137 apr 2 11:51 mp3.pl
-rwxr-xr-x 1 root root 268 mrt 24 00:22 printenv
-rwxr-xr-x 1 root root 14662 mrt 27 13:51 test1.mp3
-rwxr-xr-x 1 root root 16752 mrt 27 13:51 test2.mp3
-rw-r--r-- 1 root root 0 apr 2 23:28 test2.pl
-rwxrw-rw- 1 Temmink Temmink 0 apr 2 23:29 test3
-rw-rw-r-- 1 Temmink Temmink 7 apr 5 00:29 testarno.pl
-rwxr-xr-x 1 root root 757 mrt 24 00:22 test-cgi
-rwxr--r-- 1 Temmink root 389 apr 2 12:12 testdir.pl
-rw-r--r-- 1 root root 521 mrt 29 23:53 testmp3.pl
-rwxr-xr-x 1 root root 3601 mrt 27 13:51 test.pl
-rw-r--r-- 1 root root 5 apr 5 00:28 testroot.pl
-rw-r--r-- 1 Temmink Temmink 8350342 mrt 29 23:27 totalScience.mp3
krijg ik deze output.
Contents of the current directory:
test1.mp3
printenv
test-cgi
test2.mp3
test.pl file 0
totalScience.mp3
testmp3.pl
testdir.pl file 389
lib.pl file 0
mp3.pl file 158
list.pm file 2079
arno
arno2
test2.pl
test3
testroot.pl file 0
testarno.pl file 9
Heeft iemand een idee waarom niet alle files als file worden gezien, en ook directories niet? Aan de rechten kan het volgens mij niet liggen.