Showing results for 
Search instead for 
Did you mean: 

Remote copy file

Regular Advisor

Remote copy file

I have three servers ( serverA , serverB , serverC ) , they are in my network but different subnet , serverA and serverC can not directly connected to each other as no tunnel is established among them , while serverB can connect another two servers ( A and C ) .

Now , I have a schedule job to regularly copy file from serverA to serverC , as they are can not connected , I used to copy it to serverB first then finally to serverC ( run another batch from server B ) , but I found that the server system time will be varied ( may be a fwe seconds after a period of time ) , so that the file even copied to serverC but maybe not in the same date ,

can advise if I want the copy process ( from serverA to server B then to serverC ) by ONE single script , what can i do ? thx

Re: Remote copy file

You can copy from A to B by rcp, ftp, scp, etc.
Once it is on B, you can use remsh/ssh to use any of the above to copy to C.
Steven Schweda
Honored Contributor

Re: Remote copy file

Why not run a "tar" pipeline on system B?
A Forum search for, say,
tar pipeline
should find many examples (some better than

This assumes that a user on system B can use
ssh or rsh/remsh to run a process on systems
A and C.

> [...] so that the file even copied to
> serverC but maybe not in the same date [...]

Copied how?

Why not add some routes and do things the
easy (direct) way? If B can talk to A and C,
then is there any good reason that A can't
talk directly to C?
Esteemed Contributor

Re: Remote copy file

while you are copy files from serverA to serverB should use -p in your scrip,

-p (preserve permissions) Causes cp to preserve in the copy as
many of the modification time, access time, file mode, user
ID, and group ID as allowed by permissions.

otherwise tar will be best option, thanks,
Viktor Balogh
Honored Contributor

Re: Remote copy file

if you have time differences don't use nfs, any of the other methods are welcome. (scp, rcp, rsync, tar trough ssh,...)

# tar cvf - file | ssh hp01a01.w1 "cd \
/root;tar xfv - file"

If I were you, I would write a script on machine B to fetch the file from A and then pass it to system C, this requires ssh key-based authentication. Or just set up routing...
Unix operates with beer.
Sajjad Sahir
Honored Contributor

Re: Remote copy file

u can see the man pages of the following commands
rcp, ftp, scp
u can use all these commands

thanks and regards

Sajjad Sahir
Volker Borowski
Honored Contributor

Re: Remote copy file

Not that I ever tried it, but shouldn't

rcp -p hosta:/sourcedir/file hostc:/targetdir/file

executed on server B do the job ?