tags:

views:

75

answers:

2
REMOTE SERVER
remsh remoteserverhostname -l remoteusername find /tmp/a1/ | cpio -o > /tmp/paketr.cpio

LOCAL SERVER
rcp remoteserverhostname:/tmp/paketr.cpio /tmp/aaa
cpio -idmv < /tmp/paketr.cpio

i'am trying to get and create directory structure from remote server to local server i can do this with following command list but i wonder if i can do this with just one command

by running cpio with pass-through mode

remsh remoteserverhostname find /tmp/a1 | cpio -pd /tmp

current </tmp/tmp/a1/b1/y1> newer
current </tmp/tmp/a1/b1/z1> newer
current </tmp/tmp/a1/b2/l2smc> newer
"/tmp/a1/b3": No such file or directory
Cannot stat </tmp/a1/b3>.
0 blocks

so when i try to cpio -pd option , i am expecting it to create directories for me but it does not

i was using rcp but its not preserving symbolic links :(

what can i do ? hp-ux

+1  A: 

Use rsync.

Paul R
+2  A: 

Are you trying to copy just the directory structure (i.e. directories only), or the files too? If copying everything, try:

ssh remoteserverhostname 'find /tmp/a1 | cpio -o' | cpio -idmv

If just the directories, then use:

ssh remoteserverhostname 'find /tmp/a1 -type d | cpio -o' | cpio -idmv

(I recommend ssh rather than remsh, as it's way more secure, but the same commands ought to work with remsh too...)

psmears
thanks you saved me :))
soField
i need to preserve owner of file any comment ?
soField
and what about zipping file while transfer and reopen it on local machine
soField
For compression - if using `ssh` just add the `-C` option before the server name. For preserving the owner - `cpio` should do this automatically, but can only do so if running as root.
psmears
is there any option for preserve owner for other users if i want to use this command with other non root user what can i do ? i am using remsh so C option is available for it ?
soField
No - normal users can't create files owned by other users (it's part of the Unix security model). I really strongly advise using `ssh` rather than `remsh`; `remsh` has huge security issues. If you must use it with compression, try adding `| gzip -` after `cpio -o`, and `gunzip - |` before `cpio -idmv`. (Use `bzip2`/`bunzip2` if they're installed on your system for better compression.)
psmears