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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting I need script Copy permissions of files and folders from one server to another
# 8  
Old 08-17-2010
The directory when i can run the scrip is in "/" with all directoris.

my answer is.. what is the comand chmod.. to run with a file_perms.sh

---------- Post updated at 04:53 PM ---------- Previous update was at 04:40 PM ----------

i repittt...

i work in /
# 9  
Old 08-17-2010
Use find

Hi,

If both the servers were identical prior to change ,then on the server thats good run the following

Code:
find / -type -printf "%h/%f %m\n" >> /root/do-restore.sh

Then copy the /root/do-restore.sh to the server you have accidentally changed the permissions , I would say a quick way would be cat the file ,run a while loop and do chmod something like

Code:
cat /root/do-restore.sh|while read IN
do
fn=`echo $IN|awk '{print $1}'`
per=`echo $IN|awk '{print $2}'`
chmod $per $fn
done


Last edited by maverick_here; 08-17-2010 at 12:14 PM.. Reason: encoding
These 2 Users Gave Thanks to maverick_here For This Post:
# 10  
Old 08-17-2010
Quote:
Originally Posted by maverick_here
Hi,

If both the servers were identical prior to change ,then on the server thats good run the following

Code:
find / -type -printf "%h/%f %m\n" >> /root/do-restore.sh

Then copy the /root/do-restore.sh to the server you have accidentally changed the permissions , I would say a quick way would be cat the file ,run a while loop and do chmod something like

Code:
cat /root/do-restore.sh|while read IN
do
fn=`echo $IN|awk '{print $1}'`
per=`echo $IN|awk '{print $2}'`
chmod $per $fn
done

A nice Linux option Smilie Thanks!

If you run it this way, then you can just copy the file to the target and run it...
Code:
find / -type f -o -type d -printf "chmod %m %h/%f\n" > /root/do-restore.sh

This User Gave Thanks to Scott For This Post:
# 11  
Old 08-17-2010
Until we find out what the O/P actually typed I'd be wary of doing a blunt permissions change from root.
Knowing what was actually typed would help cut the list down because we could no doubt compose a "find ..... -perm ..." statement.

The script posted above will misbehave with filenames containg space characters. If we introduce a delimiter in the "printf" it would be improved.

Cautious approach would be to run the "find" process on both computers for all inodes (not just files), then sort and compare the two listings to see what we are up against. Even on similar systems I would expect differences which must be ignored.
This User Gave Thanks to methyl For This Post:
# 12  
Old 08-19-2010
I use the script and are tot ok...

very tnaks for allll...

regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question