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

chmod fails

by Umdurman (Acolyte)
on Aug 14, 2020 at 20:33 UTC ( [id://11120745]=perlquestion: print w/replies, xml ) Need Help??

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

Dear friends, I have a nasty problem. I am running a webserver on OSX. The images for the webserver are produced on a Windows machine. The Windows machine has a network connection with the OSX Server. Once the images are ready we drag and drop them from the PC into the image directory on the Mac. If I look in the info of the transferred files I see the owner is the same as the server but everyone is "no access". The image files fail to render in the webserver. I figured to make a nice script that chmods the transferred files and copy them in the right directory. Chmodding however does not work at all. I used to do this file preparing from one Mac to the other, the Server without this problem. Anyone with bright idears? Thanks in advance! No special code, just : chmod 755, $file_name or die "Can't chmod $old because: $!\n"; Please see this link to illustrate the problem: https://apple.stackexchange.com/questions/316205/no-write-permissions-after-copy-files-from-windows Ton

Replies are listed 'Best First'.
Re: chmod fails
by hippo (Bishop) on Aug 14, 2020 at 22:46 UTC
    chmod 755, $file_name or die "Can't chmod $old because: $!\n";

    That's not octal.


    🦛

      To futher hippo's reply 755 decimal is 1353 octal.

      In UNIX terms this corresponds to t-wxrw--wx. As you can see the owner won't have read permission.

      Sorry, forgot the leading 0, that I use it in all my code, 0777 for instance
Re: chmod fails
by Your Mother (Archbishop) on Aug 15, 2020 at 02:38 UTC

    To futher wazat’s reply to hippo’s reply… You can write bare octal numbers in perl with a leading zero. perldoc chmod has some examples.

    moo@cow[18]~>touch bingo moo@cow[19]~>ls -laF bingo -rw-rw-r-- 1 moo staff 0 Aug 14 22:31 bingo moo@cow[20]~>perl -E 'chmod 0624, "bingo"' moo@cow[21]~>ls -laF bingo -rw--w-r-- 1 apv staff 0 Aug 14 22:31 bingo moo@cow[22]~>perl -E 'say 0755; printf "%o\n", 493' 493 755
Re: chmod fails
by stevieb (Canon) on Aug 14, 2020 at 20:39 UTC

    Post the code you have that doesn't work so we have something to review. We're not going to write something for you without you showing the attempt(s) that you've made.

      Thank you guys, this problem is not about how to chmod but how to make sure to get permissions right when copying files from Windows to Mac directories. I found the solution though. Made a multi-file upload script to transfer the files. Then all permissions will stay okay;-) The script also distributes the uploaded files in one of the 20 special directories for me. After checking if the files are valid;-) Ton

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found