Operating System - HP-UX
1834427 Members
1685 Online
110067 Solutions
New Discussion

Re: rcp -p ,didn't get the same attribute

 
kyliu
Occasional Advisor

rcp -p ,didn't get the same attribute

Dear Sir,
I use rcp command to get lots files,
and I don't want to change files' owner after rcp finished.

So that, I add option (-p) .

After rcp finished , I checked owner who is root .

Why does that happen ?
How should I do ,that can get the same owner within files?
command is blow:
"rcp -p gbm2:/home/erpmgr/sqlnet.log . "

thank you in advance ,
KY Liu
9 REPLIES 9
A. Clay Stephenson
Acclaimed Contributor

Re: rcp -p ,didn't get the same attribute

The -p option preserve the mode of the file; that is not the same as owner/group. Those attributes are determined by the uid/gid of the rcp process. You need to rethink your problem using cpio or tar to preserve all the attributes or do a fixup pass after the copy to matchg the owner:group but make sure that you do both owner and group in one chmod because once you no longer own the file, you won't be able to change the group.
You simply read something into rcp -p that was not there.
If it ain't broke, I can fix that.
violin_1
Advisor

Re: rcp -p ,didn't get the same attribute

KY and me are co-workers, and we did some test by cp command , logged as attached,

"cp -rp" could keep permissions and owners/groups ,
but we need to clone a unix server at this weekend , we need to "rcp" for short down time.

Is any possible option for 'rcp' command funtional as 'cp -rp'?

Thanks for any tips.

Violin.
A. Clay Stephenson
Acclaimed Contributor

Re: rcp -p ,didn't get the same attribute

No and you are also going to lose things like setuid bits; however, as I mentioned earlier tar or cpio will handle this -- as long as the files are 2GB or less. If you are using larger files then fbackup/frecover can be used. It's rather easy to setup a pipeline that fbackup's to a remsh'ed frecover -- and all the file attributes will then be retained.
If it ain't broke, I can fix that.
Eknath
Trusted Contributor

Re: rcp -p ,didn't get the same attribute

Hi Kyliu,

One more options is let the user do rcp (not root) whose permissions are required for the files. But you may have to modify the .rhosts file.

Cheers!!!
eknath
kyliu
Occasional Advisor

Re: rcp -p ,didn't get the same attribute

Dear all,
Thank you for your help ,
For now,I know how to do this .

KY
vinod_25
Valued Contributor

Re: rcp -p ,didn't get the same attribute

hi Liu

The functionality that is being described above is what is intended with
rcp -p. The rcp -p command (by design) doesn't allow the
preserving of the UID:GID on copied files unlike cp -p. Copying the
UID:GID across remote systems represents a security problem. The command rdist
may be used as an alternative. Consulting the manpage for rcp(1):

-p Preserve (duplicate) modification times and modes (permissions) of
source files, ignoring the current setting of the umask file creation mode
mask. If this option is specified, rcp preserves the sticky bit only if the
target user is superuser.

While, the -p option does duplicate the modification times and modes, it
does not duplicate the owner and group of the file. This will be determined, by
the UID:GID of the user executing the rcp.

Try 'rdist'

Regards

Vinod K

Bob_Vance
Esteemed Contributor

Re: rcp -p ,didn't get the same attribute

'fbackup' is your friend -- and faster than 'tar' for big copies -- and it preserves ACLs.

Here's a technique that I often use to copy over the network:

## copying /big_dir on source-host to /big_dir on target-host,
## on target host (not source host), execute

# (remsh source-host cd / \; fbackup -i big_dir -f -) | (cd / ; frecover -r -f - )

Pay attention to the parentheses and the "\;" in the first command and simply ";" on the second. The \ escape is necesary in the first one because we want it executed by remsh on the remote (source) system. The "-f -" , means standard input/output.

Also note the 'cd' and the relative path names "big_dir" rather than absolute "/big_dir". This would allow a change of location on the target host, if desired.
E.g., suppose we wanted "/old/big_dir" to become "/new/big_dir". Then the command would be:

# (remsh source-host cd /old \; fbackup -i big_dir -f -) | (cd /new ; frecover -r -f - )


hth
bv
"The lyf so short, the craft so long to lerne." - Chaucer
violin_1
Advisor

Re: rcp -p ,didn't get the same attribute

I got a better idea!

"NFS + cp -rp" could solve our problem.
and no command needs to test.

Bingo!

Violin.
Muthukumar_5
Honored Contributor

Re: rcp -p ,didn't get the same attribute

rcp with -p will keep time information, permission and ACL details. However it will not be holding owner,group names.

You can do it by,

1) cp -rp using NFS mount.
2) Before rcp a file, do like ls -l and put it as filename.per. rcp -p the specific file and change the permission in the local machine with owner and group.

hth.



Easy to suggest when don't know about the problem!