Operating System - HP-UX
1834178 Members
2438 Online
110064 Solutions
New Discussion

Need some debugging here!

 
SOLVED
Go to solution
MAD_2
Super Advisor

Need some debugging here!

I wrote the small script attached and am using it to transfer complete directories from one server to another. However, the problem I am encountering is that the subdirectories are being created twice, i.e.

I specify local directory: /home/mad/tst
this one also has within directories tst2 and tst3

Then I specify the remote directory to be: /home/mad

It's creating the following:

/home/mad/tst
/home/mad/tst/tst2
/home/mad/tst/tst3
and also...
/home/mad/tst2
/home/mad/tst3

I desire the first three, but the last two are not what I intended, any idea why those are being created?
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with
3 REPLIES 3
S.K. Chan
Honored Contributor
Solution

Re: Need some debugging here!

Ok, this is what happened. First of all these dirs will be processed by the for loop ..
1) /home/mad/tst
2) /home/mad/tst/tst2
3) /home/mad/tst/tst3

The first loop will copied "tst" dir and all other dirs under it to $SERVER:/home/mad. So after the 1st for loop, you would have this in $SERVER already ..

/home/mad/tst
/home/mad/tst/tst2
/home/mad/tst/tst3

because it's a recursive copy "-r".

Now going into the 2nd loop, "/home/mad/tst/tst2" directory will be copied over to /home/mad which result in the destination server having ..

/home/mad/tst2

Same argument when it goes into the 3rd loop, which wil result in ..

/home/mad/tst3 be created.

If your goal to to copied everything under /home/mad/tst (including tst) to another server in /home/mad, you don't need the for loop since you've already given the "-r" option in your rcp command.
Helen French
Honored Contributor

Re: Need some debugging here!

Hi,

The reason is that you are using multiple loops here above a recursive copy. The 'for' loop is not necessary there. You can just remove it and use only the rcp -r command. This will copy the subdirectories to the remote hosts.

HTH,
Shiju
Life is a promise, fulfill it!
MAD_2
Super Advisor

Re: Need some debugging here!

Thanks, now it's working the way I wanted it to work!
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with