Reading directories, entering directories, chaning file permissions... 
Author Message
 Reading directories, entering directories, chaning file permissions...

I am trying to create a script taht will do the following:

- Get a list of the directories in a given folder.
- Enter each of these directories, and chmod all files to 777 in each and
every directory.

I figure that the best way of doing this is through a telnet interface,
since you've got your own permissions instead of Perl's permissions like
through a html page. (don't you???)

Here's what I've come up with, but it doesn't seem to do the trick. Any help
whatsoever is greatly apprecciated.

thnx

Asbjorn

########## The script : ###########
# :'s and .'s are used as progress indocators
#one : is printed for each directory, and one . is printed for each file.

#!/usr/local/bin/perl -w

$dir = "/usr/sites/blitzkrieg.org/blitzkrieg/members";

use Benchmark;
   $t0 = new Benchmark;

chdir ($dir) || die "Can't change directory!";


closedir(DIR);


$processed = 0;
$dirs = 0;

print "Files: $fnum";


 chomp ($file);
 print ":";
 opendir(D, $dir/$file) || die "Can't read directory 3";

 closedir(D);
 $dirs++;

  chomp($member);

  print ".";
  $processed++;
 }

Quote:
}

if ($errors[0]) {
print "The following files returned errors:";

  print "$error\n";
 }
Quote:
}

print "\n $processed files in $dirs directories processed! ";

$t1 = new Benchmark;
$td = timediff($t1, $t0);

print "Execution time:",timestr($td),"\n";

exit;



Sat, 27 Oct 2001 03:00:00 GMT  
 Reading directories, entering directories, chaning file permissions...

Quote:

> I am trying to create a script taht will do the following:

> - Get a list of the directories in a given folder.
> - Enter each of these directories, and chmod all files to 777 in each and
> every directory.

> I figure that the best way of doing this is through a telnet interface,
> since you've got your own permissions instead of Perl's permissions like
> through a html page. (don't you???)

> Here's what I've come up with, but it doesn't seem to do the trick. Any help
> whatsoever is greatly apprecciated.

> thnx

> Asbjorn

> ########## The script : ###########
> # :'s and .'s are used as progress indocators
> #one : is printed for each directory, and one . is printed for each file.

> #!/usr/local/bin/perl -w

> $dir = "/usr/sites/blitzkrieg.org/blitzkrieg/members";

> use Benchmark;
>    $t0 = new Benchmark;

> chdir ($dir) || die "Can't change directory!";

> opendir(DIR, ".") || die "Can't open directory";

> closedir(DIR);

> print "Processing : <br>";

> $processed = 0;
> $dirs = 0;

> print "Files: $fnum";


>  chomp ($file);
>  print ":";
>  opendir(D, $dir/$file) || die "Can't read directory 3";

>  closedir(D);
>  $dirs++;

>   chomp($member);

>   print ".";
>   $processed++;
>  }
> }

> if ($errors[0]) {
> print "The following files returned errors:";

>   print "$error\n";
>  }
> }
> print "\n $processed files in $dirs directories processed! ";

> $t1 = new Benchmark;
> $td = timediff($t1, $t0);

> print "Execution time:",timestr($td),"\n";

> exit;


Dimitri



Sun, 28 Oct 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Chaning file/folder permission on Windows

2. File Directory and read File

3. Reading files in a directory and printing to one txt file

4. Security: Overwriting directory file when removing directory?

5. Zip files in a directory by zipping directory

6. Security: Overwriting directory file when removing directory?

7. help selecting and displaying specific files after reading directory:

8. problems with reading a file from a directory

9. finding a file in a directory and reading it

10. Win32::File - Reading NTFS directories

11. Reading file names but not directories

12. Q: How to read all the file name in a directory

 

 
Powered by phpBB® Forum Software