Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

simple chmod

by wolverina (Beadle)
on Dec 25, 2003 at 23:22 UTC ( [id://317020]=perlquestion: print w/replies, xml ) Need Help??

wolverina has asked for the wisdom of the Perl Monks concerning the following question:

This dosen't change the permission for $A_file... Why? -Lisa
$A_file = "file1.cgi"; $B_file = "file2.cgi"; use File::Copy; copy ($B_file, $A_file); chmod 0755, $A_file;

Replies are listed 'Best First'.
Re: simple chmod
by TVSET (Chaplain) on Dec 25, 2003 at 23:58 UTC
    The code itself looks OK. First, you can examine chmod's return value. Manual says that it returns the number of successfully chmod'ed files. So you can do something like:

    chmod $mod, $file or die "Couldn't chmod $file";

    Then you can check if you have enough permissions to change attributes of the file. If you want to incorporate this checks into your program, then read the "perldoc -f -X".

    HTH.

      chmod $mod, $file or die "Couldn't chmod $file";
      A good suggestion, but lacking. If you add just five or so characters you get something much more useful:
      chmod $mod, $file or die "Couldn't chmod $file: $!\n";
      That will probably reveal the reason for the chmod failure without requiring any further investigation.

      Makeshifts last the longest.

        Actually, that is what I was writing, but didn't finish for some reason. :)
        I guess I need more sleep rather then more of these NOC shifts. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://317020]
Approved by exussum0
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-09-16 05:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.