Advertisement
Guest User

Untitled

a guest
May 28th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. use File::Find;
  4. use Cwd 'abs_path';
  5. #$max_depth = 2;
  6.  
  7. if( 1 != @ARGV )
  8. {
  9. print "błąd. Niepoprawna liczba argumentów\n";
  10. exit 1;
  11.  
  12. }
  13.  
  14. if ( ! -d $ARGV[0] )
  15. {
  16. print "błąd. plik nie jest katalogiem\n";
  17. exit 1;
  18.  
  19. }
  20.  
  21. my @arr;
  22.  
  23. find(\&code, $ARGV[0]);
  24.  
  25. sub code
  26. {
  27. if($_ ne "."){
  28. if ( -d $_ )
  29. {
  30.  
  31. my $mode = (stat _)[2];
  32.  
  33. $mode = $mode & 07777;
  34. my $usr = ($mode & 0700) >> 6;
  35. my $grp = ($mode & 0070) >> 3;
  36. my $real = abs_path($_);
  37.  
  38. if($usr>0 and $grp==0){
  39. push @arr, $_;
  40. }
  41.  
  42. #printf "$real has permissions %04o (%i,%i,%i)\n", $mode, $usr, $grp;
  43.  
  44. }
  45. }
  46.  
  47. }
  48.  
  49.  
  50. my @sorted = sort @arr;
  51. $" = "\n";
  52. print "@sorted";
  53. print "\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement