Operating System - HP-UX
1842067 Members
2250 Online
110186 Solutions
New Discussion

duplicates using rcp command

 
SOLVED
Go to solution
Henry Chua
Super Advisor

duplicates using rcp command

Hi Guys,

I have written a script to loop copy a list of files:
"DIR1/file1
DIR1/DIR2/file2
DIR1/DIR2/DIR3/file3
DIR4/file4"
DIR4/DIR5/file5"
DIR4/DIR5/file6"
DIR4/DIR5/DIR6/file7"

remotely over to another box using rcp command.

"rcp -rp $Sourcepath root@$R_HOSTNAME:$remotepath"

however when the 1st loop is completed, it would have already copied everything over.. and the nex two loop will only create duplicates over at the other box...

Can I prevent the rcp from creating unecessary duplicates?

thank u..
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: duplicates using rcp command

I don't quite understand what you mean about the 1st loop and "next two loop" though.

How exactly did you write your script? That would help us in troubleshooting.

Whatever method you use, duplicate files will not be created. It will merely overwrite what is already there.
Biswajit Tripathy
Honored Contributor
Solution

Re: duplicates using rcp command

I don't understand the question either, but I'm
guessing that you want to remote-copy the file only if
it does not exists in the remote machine. If that's the
case, do the following:

rexec $R_HOSTNAME -l root "ls $remotepath 2> /dev/null" | grep -q $remotepath
if [ $? -eq 1 ]
then
rcp -rp $Sourcepath root@$R_HOSTNAME:$remotepath
fi

- Biswajit
:-)
Henry Chua
Super Advisor

Re: duplicates using rcp command

Hi Tripathy, that exactly the answer I need.. many many thanks.. i was creating a script to provide incremental backup for my box.. I have attached the script if u are interested to see my primitive codes..

Thanks Guys!!!