retain ownership


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users retain ownership
# 1  
Old 12-01-2011
retain ownership

Hi,
I have a script which transfers files/directories from one HP unix to another HP unix server using SCP but i need to retain ownership of files/folders same as source server my script is as follows

PHP Code:
cd /sasdata/TR_CNTO328/C0328T07/Dry_Run_1/Macros
find 
. -type d -newer . -exec scp -pr {} sasadmin@targetserver:/sasdata/TR_CNTO328/C0328T07/Dry_Run_1/Macros ';' 
,
permission,timestamp remains same as source server but ownership of files/folders getting changed,I need to know why this is happening or is there any parameter which i need to mention in my script.

Last edited by tushar_spatil; 12-01-2011 at 06:02 AM.. Reason: addon error
# 2  
Old 12-01-2011
As per the scp manual page, the -p option does not preserve ownership. And this makes sense, as the user "sasadmin" is the owner of the destination. If you can log into the destination system as root, you could use tar or cpio to preserve ownership.
# 3  
Old 12-01-2011
Hi
Thanks for reply i have to use scp only. then how to preserve ownership in scp
any help will be appriciated

Thanks and Regards
# 4  
Old 12-01-2011
You don't.

Create a tarball and copy it over with scp. The tar files will preserve ownership when root extracts them.
# 5  
Old 12-01-2011
use rsync over ssh
# 6  
Old 12-01-2011
rsync is an alternative way to copy files from system to system - but it uses ssh to make the connection. And it will not preserve ownership unless you are connecting as root on the destination system.

Another alternative is nfs and its ilk - sharing out a directory would preserve ownership -- by UID.
# 7  
Old 12-02-2011
thank you all for your response i just got to know that one can not retain ownership of file/directory while SCP!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete and retain some characters

Ive been trying to google and tried sed and awk. BUt still getting no exact formula. I would like to know how to parse this at: From: Compute Machin Appliance 3.2.9.10000 123456 To: Compute Machin Appliance 3.2.9.123456 (5 Replies)
Discussion started by: kenshinhimura
5 Replies

2. Shell Programming and Scripting

retain negative value through sed command

Hi Experts , We have a reuirement that we have to remove multiple comma's within double quotes in the columns as we have already taken care through our sed command . Here is my code :- sed -e ':a' -e 's/\("*\),\(*"\)/\1\2/;ta' $Orign_File > $dummy sed 's/"//g' $dummy > $Process_file ... (14 Replies)
Discussion started by: bshivali
14 Replies

3. Shell Programming and Scripting

how to retain zero

Hi everyone i have simple mathematical problem bash> echo date +%m bash> 03 bash> month=`date +%m` bash> lmonth=$month-1 bash> echo $lmonth bash>2 it gives me two but i want the answer of 02 please help me how to do this (6 Replies)
Discussion started by: aishsimplesweet
6 Replies

4. Shell Programming and Scripting

How to retain blank spaces in AWK?

Hi all, I have space delimated file which look like this 1 2 3 4 5 6 7 8 9 1 0 11 I am using simple awk command to read the second column awk '{print $2}' input_file but i got the output like this which also read 10 from the third column 2 6... (8 Replies)
Discussion started by: bsn2011
8 Replies

5. Shell Programming and Scripting

Replace and retain entries.

Replace and retain entries. I have a certain users that will replaced a certain values, but if it has already a value it will retain its values. Thanks Data to be placed: account_locked = false loginretries = 0 pwdwarntime = 0 ... (4 Replies)
Discussion started by: kenshinhimura
4 Replies

6. Shell Programming and Scripting

Need to retain particular rows

Hi All, I am in need of help to retain particular rows. I have a large file with 5 columns. Column 3 has signs like “=” “>” “<” and column 5 has values “nm” “%” or empty space. I need to keep only rows which have “=” in column 3 and “nm” in column 5. How can I do it in awk? Any help is greatly... (3 Replies)
Discussion started by: newpro
3 Replies

7. Shell Programming and Scripting

Retain File Timestamp

There are directories of files that I have to run the dos2ux command on to get ride of the carriage return characters. Easy enough, but I have to retain the original timestamps on the files. I am thinking that I am going to have to strip off the timestamp for each file and convert it to unix time... (3 Replies)
Discussion started by: scotbuff
3 Replies

8. Shell Programming and Scripting

Retain 3 latest files

Guys, Please can you tell me how to retain 3 latest files in a directory and get rid of the rest ? Thanks very much Regards, Ganesh (6 Replies)
Discussion started by: kamathg
6 Replies

9. Shell Programming and Scripting

how to retain leading zeros

Hi All, I am working with a fixed width file Forrmat. C1 Number (10,3) C2 Number (10,3) e.g. c1= 0000000100.000 c2= 0000000020.000 0000000100.0000000000020.000 I have to perform c1 - c2 . i.e. I want answer to be 0000000080.000. but I am loosing the leading zeros( only getting... (3 Replies)
Discussion started by: Manish Jha
3 Replies

10. UNIX for Dummies Questions & Answers

how to retain text using pax

I have a .tar file consisting of text and binary files. I ftp'd the .tar file using ftp binary. when I did the pax to unwind the tar file, I noiticed that the text files were encoded in binary. **How would I retain the text characteristics of the ascii text files, while also keeping the... (11 Replies)
Discussion started by: idic5
11 Replies
Login or Register to Ask a Question