tags:

views:

57

answers:

2

HI, Actually i am trying to reduce the time taken to transfer N-number of files from remote machine local machine using secure file transfer, previously i used scp system command it establishes a connection for each file transfer. Thanks in advance.

A: 

I think this would create a separate connection each time. However, scp with the -r flag (which Net::SCP uses) recursively copies all of the files in a directory with a single connection. That might be the way to go, if you have your files in a few directories and you want to copy all of the files in those directories.

Otherwise, rsync with the --files-from option should use only one connection. (Don't forget -z for compression, or -a).

If the only reason you're considering using perl to do this is that you want a single session, then just use the command line rsync to get this effect (with --files-from). If you want perl power to generate the list of files-from, File::Rsync supports that.

masonk
+1  A: 

Unless you have a bandwidth cap on each individual TCP connection, you are not going to get a significant reduction in download time by using multiple SCP connections.

You can check whether you get a speed up by putting a separate scp command for each file in a shell script and timing the script. Then rerun the shell script with & at the end of each scp line. If this speeds up the transfer and you want to really do this in Perl, look into fork or Parallel::ForkManager.

imran