Sponsored Content
Top Forums Shell Programming and Scripting I need script Copy permissions of files and folders from one server to another Post 302445919 by Scott on Tuesday 17th of August 2010 07:16:12 AM
Old 08-17-2010
Hi.

Not sure if this is so great, but based on this thread: https://www.unix.com/unix-dummies-que...ssion-bit.html

Run this on the server with the good permissions:
Code:
find / -type f -o -type d 2>/dev/null | while read FILE; do
  perl -le'
    printf "chmod %o \"%s\"\n", 07777 & (stat)[2], $_
    for @ARGV
  ' "$FILE"
done > /tmp/file_perms.sh

Copy and run /tmp/file_perms.sh on the server with the "bad" permissions.

Good luck Smilie
This User Gave Thanks to Scott For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

Copy Folders from Sun Solaris to Windows server.

Hi, I have a folder with diff subfolders in my Unix box and now I want to ftp all the floders into my Windows machine. Is there any easy way to do that. When I use the "mget " cmd and try to FTP the files, it throws an error that the sub folder name does not exist. Can you someone help in... (3 Replies)
Discussion started by: chandu_kalari
3 Replies

2. Shell Programming and Scripting

Helppppppp I need script Copy permissions of files and folders from one server to another

Helpppppppppppppp Hi.. I have 2 servers with linux suse10. I made a mistake and on one of the servers changed with chmod the permission of root in directory /. In the other servers the permissions are correct Please i need a script, to change the permissions of one server 1, using... (1 Reply)
Discussion started by: ave-phoenix
1 Replies

3. Windows & DOS: Issues & Discussions

Windows mass copy files with same name in differnt folders

I have files existing with same names in the folders with date as display below c:\2010-09-10 <==== folder arr1.jpg arr2.jpg arr3.jpg arr4.jpg c:\2010-09-09 <==== folder arr1.jpg arr2.jpg c:\2010-09-08 <==== folder arr2.jpg arr3.jpg arr4.jpg ... (5 Replies)
Discussion started by: jville
5 Replies

4. UNIX for Dummies Questions & Answers

copy mutilple files to mutiple folders

Hi, I just started to learn shell progamming and just can't get my head around the following problem. I need to do the following: I have a folder which contains 100+ subfolders. Inside these subfolders there is one folder named 'Morph' and several jpg's. I need to copy all the files into... (4 Replies)
Discussion started by: M474746
4 Replies

5. Shell Programming and Scripting

Loop folders, delete files, copy new ones

Folks, I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
Discussion started by: acraig
6 Replies

6. Shell Programming and Scripting

Linux Script to compare two folders and copy missing files

Hi, I need help in shell scripting. If someone can help me, that would be great! Problem. I want Linux Script to compare two folders and copy missing files. Description. I have two directories /dir1 /dir2 I need to copy all distinct/new/unique/missing files from /dir1 and that... (1 Reply)
Discussion started by: S.Praveen Kumar
1 Replies

7. HP-UX

Recursive copy of Folders with files

Dear All, I will appreciate any help received. Our system is running on hpux v1 My problem is as follows: We have many customer folders with name fd000100, fd000101 and so on e.g. (Testrun)(testsqa):/>ll /TESTrun/fd000100 total 48 drwxrwx--- 2 fq000100 test 96 Jun 27 2004... (17 Replies)
Discussion started by: mhbd
17 Replies

8. Shell Programming and Scripting

How do you compare two folders and copy the difference to a third folder in a remote server?

How do you compare one local folder and a remote folder and copy the difference to a third folder in a remote folder.e.g. Folder A -- Is in a remote server and it has the following files TEST1.OUT TEST2.OUT TEST3.OUT Folder B --Is in a local server and it has the following files ... (5 Replies)
Discussion started by: cumeh1624
5 Replies

9. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

10. UNIX for Beginners Questions & Answers

Command to change add permissions for a new user to all files in all subfolders and folders

Hi there! I'm new to Unix and haven't done command line stuff since MS-Dos and Turbo Pascal (hah!), I would love some help figuring out this basic command (what I assume is basic). I'd like to add a User to the permissions of all files in a folder and all files in all subfolders, as well... (9 Replies)
Discussion started by: Janjbrt
9 Replies
MKDIR(2)						      BSD System Calls Manual							  MKDIR(2)

NAME
mkdir -- make a directory file SYNOPSIS
#include <sys/stat.h> int mkdir(const char *path, mode_t mode); DESCRIPTION
The directory path is created with the access permissions specified by mode and restricted by the umask(2) of the calling process. See chmod(2) for the possible permission bit masks for mode. The directory's owner ID is set to the process's effective user ID. The directory's group ID is set to that of the parent directory in which it is created. Note: the behavior of mkdir() is undefined when mode bits other than the low 9 bits are used. Use chmod(2) after mkdir() to explicitly set the other bits (See example below). RETURN VALUES
A 0 return value indicates success. A -1 return value indicates an error, and an error code is stored in errno. ERRORS
Mkdir() will fail and no directory will be created if: [EACCES] Search permission is denied for a component of the path prefix. [EACCES] Write permission is denied for the parent directory. [EDQUOT] The new directory cannot be created because the user's quota of disk blocks on the file system that will contain the directory has been exhausted. [EDQUOT] The user's quota of inodes on the file system on which the directory is being created has been exhausted. [EEXIST] The named file exists. [EFAULT] Path points outside the process's allocated address space. [EIO] An I/O error occurred while making the directory entry or allocating the inode. [EIO] An I/O error occurred while reading from or writing to the file system. [ELOOP] Too many symbolic links were encountered in translating the pathname. This is taken to be indicative of a looping sym- bolic link. [EMLINK] The parent directory already has {LINK_MAX} links. [ENAMETOOLONG] A component of a pathname exceeded {NAME_MAX} characters, or an entire path name exceeded {PATH_MAX} characters. [ENOENT] A component of the path prefix does not exist or path is an empty string. [ENOSPC] The new directory cannot be created because there is no space left on the file system that would contain it. [ENOSPC] There are no free inodes on the file system on which the directory is being created. [ENOTDIR] A component of the path prefix is not a directory. [EROFS] The parent directory resides on a read-only file system. EXAMPLE
int main (int argc, const char * argv[]) { /* The behavior of mkdir is undefined for anything other than the "permission" bits */ if (mkdir("/tmp/blah", 0777)) perror("/tmp/blah"); /* So we need to set the sticky/executable bits explicitly with chmod after calling mkdir */ if (chmod("/tmp/blah", 07777)) perror("/tmp/blah"); } LEGACY SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> The include file <sys/types.h> is necessary. SEE ALSO
chmod(2), stat(2), umask(2), compat(5) STANDARDS
The mkdir() function conforms to IEEE Std 1003.1-1988 (``POSIX.1''). 4.2 Berkeley Distribution December 11, 1993 4.2 Berkeley Distribution
All times are GMT -4. The time now is 06:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy