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

I have a script which transfers files between 2 servers. Before transferring, the script uses mkdir to recursively create the same path as that of the files to be transferred . I'm using Perl's Net::FTP. The problem is that I realised all the directory created has the permission drwxr-xsr-x, so a different user will be unable to create more directory or add anymore file to all those directory created by the current user.

So is there anyway for me to mkdir recursively AND set permission to these folders to eg. drwxrwxsrwx or drwxrwxsr-x at the same time, so that other people can still read/write and manipulated the generated folder? Thanks in advance.

Replies are listed 'Best First'.
Re: mkdir and set permission using Net::FTP
by Corion (Patriarch) on Apr 04, 2016 at 08:17 UTC

    This really depends on how the remote FTP server implements permissions. Maybe it implements an UMASK command or maybe a CHMOD command. You will have to send this special command through a SITE UMASK or SITE CHMOD command. See the ->site method in Net::FTP.

    As an aside, you should really think about whether you still want to run data transfers over FTP. SSH offers quite convenient file transfer methods nowadays, as does HTTP.

Re: mkdir and set permission using Net::FTP
by hippo (Archbishop) on Apr 04, 2016 at 08:11 UTC

    umask should do it.

    Update for clarification: Corion's response clearly assumes that the OP is creating the dir structure on the remote server and then sending the files whereas I have assumed that the dir structure is being created on the local machine and then retrieving the files. The original question doesn't specify which is the actual scenario.