Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi I have a remote machine that has a mounted network drive.

I am trying to create a script that ask me for the name of folder I wish to copy, ssh into the remote machine and have it start the copy operation.

parallel/concurrent copy is needed as I have a time constraint.

here is what i have for now in my script in "perl" if it matters....

print `ssh -t -x rocup@factory "cp -rf $folder1/ /NFS; cp -rf $folder2/ /NFS; cp -rf $folder3/ /NFS"';

I also tried

print `ssh -t -x rocup@factory "cp -rf $folder1/ /NFS & cp -rf $folder2/ /NFS & cp -rf $folder3/ /NFS &"';

and

print `ssh -t -x rocup@factory "nohup cp -rf $folder1/ /NFS;nohup cp -rf $folder2/ /NFS;nohup cp -rf $folder3/ /NFS"';

the above operations copy one by one and it takes over an hour to do it, Im hoping that I can trim down the time a bit by doing a concurrent copy

the host factory does not have private/public key setup, so i cannot do a

ssh -f -t -x rocup@factory "cp -rf $folder1/ /NFS"; as I would need to enter password 3 times.

Thanks for helping

share|improve this question

migrated from stackoverflow.com Aug 27 '09 at 1:49

This question came from our site for professional and enthusiast programmers.

1  
Are you sure a parallel copy will be faster? –  Amuck Aug 24 '09 at 19:54
    
I am not sure, I just want to try it out. When I am using filezilla (which has built in concurrent transfer) it did made the file transfer faster –  alan Aug 24 '09 at 19:58
add comment

1 Answer

If you can set up private/public key to sign into your local box from the remote machine, you can do this with two scripts.

First script, located on your box is what you run and takes as input the folders you want to copy. It does several things:

  1. Output a second script with copy commands:

    cp -rf $folder1/ /NFS &
    cp -rf $folder2/ /NFS &
    cp -rf $folder3/ /NFS &

  2. chmod the generated script 755

  3. ssh into the remote machine with this command:

    ssh rocup@factory "scp yourmachine:/path/to/generated/script ./ && ./script"

That last command requires that your user on the remote machine has a private key without a passphrase to scp back into where your generated script was created. There are ways around using a passphraseless key (forwarding agents) but this quick and dirty way can at least form a proof of concept as to whether the concurrent copy saves any time.

share|improve this answer
    
my guess is that it won't be any faster than sequential copy (drive heads moving a lot and such), but I suppose it could be. –  warren Mar 17 '10 at 15:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.