How to check in Perl if the file permission is greater than 755?

后端 未结 2 1040
别跟我提以往
别跟我提以往 2021-01-18 19:40

For a unix file, I want to know if Group or World has write permission on the file.

I\'ve been thinking on these lines:

my $fpath   = \"orion.proper         


        
2条回答
  •  日久生厌
    2021-01-18 20:03

    #!/usr/bin/perl
    
    use warnings;
    use strict;
    
    chomp (my $filename = );
    
    my $lsOutput = `ls -l $filename`;
    
    my @fields = split (/ /,$lsOutput);
    
    my @per = split (//,$fields[0]);
    
    print "group has write permission \n" if ($per[5] eq 'w');
    
    print "world has write permission" if ($per[8] eq 'w');
    

提交回复
热议问题