User Profile

Collapse

Profile Sidebar

Collapse
31special
31special
Last Activity: Jul 18 '08, 06:49 PM
Joined: Jul 17 '08
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • 31special
    replied to Reading folder content and permissions
    in Perl
    I had to do it this because that test condition using the -x was not working for me.

    Code:
    #!/usr/bin/perl
    my $dir_to_process = "/tmp";
    my @files = split("\n", `find $dir_to_process -type f -perm -o+rx`);
    foreach my $filename (@files) {
    print "Do something on ($filename)\n";
    }
    See more | Go to post

    Leave a comment:


  • 31special
    replied to Reading folder content and permissions
    in Perl
    The line print "Do something"; now prints 3 times but of the 3 files inside /tmp onle 1 of them is executable.

    Code:
    #!/usr/bin/perl
    
    my $dir_to_process = "/tmp";
    opendir (DIR, $dir_to_process) || $dir or die "Cannot open $dir: $!";
    
    while (my $name = readdir DIR) {
    next if $name =~ /^\./;
    
    $filename =  "/tmp/".$name;
    
    if (-x $filename)
    ...
    See more | Go to post

    Leave a comment:


  • 31special
    replied to Reading folder content and permissions
    in Perl
    I uncluded the line $filename = "/tmp/".$name."\n "; to make the path absolute and is not detecting that is executable.

    The -x should find out if the file is executable then it will perform the action inside the the braces?

    Code:
    #!/usr/bin/perl
    
    my $dir_to_process = "/tmp";
    opendir (DIR, $dir_to_process) || $dir or die "Cannot open $dir: $!";
    
    while
    ...
    See more | Go to post

    Leave a comment:


  • 31special
    started a topic Reading folder content and permissions
    in Perl

    Reading folder content and permissions

    I want to tweak a small program I'm creating. It will read a directory and if it finds a file inside the directory with executable permissions it should do something.

    Code:
    #!/usr/bin/perl
    
    my $dir_to_process = "/tmp";
    opendir (DIR, $dir_to_process) || $dir or die "Cannot open $dir: $!";
    
    while (my $name = readdir DIR) {
    
    next if $name =~ /^\./;
    
    
    if
    ...
    See more | Go to post
No activity results to display
Show More
Working...