ftp multiple files at the same time

Hi All,

I am using ncftpput in one of my c-shell script to upload files to a remote location. The source files keep coming continuosly and to upload each file ncftpput opens a new connection everytime. It means ncftp uploads the file1 than file2 than file3 .... There is gap 20-25 secs between each of the files and some times when its a peak time the backlog is getting too much high approx 100 source file :wink:
I have seen a project called filezilla, where you have the option to choose multiple files and its starts processing almost 2-3 files at a time. Its a great time saving tool, but I am unable to find that for AIX and there is no command line like ncftp :wall:.
Could any one among you may able to give me a hand please ?

Regards - Sraj

Looking at ncftp's man page, it seems to support what you want already.

ncftpput [options] remote-host remote-directory local-files... 

See the plural.

As for how to incorporate that into your script, that depends on how your script works, can we see it?

Hi Corno,
Here is the one line code with output....

ncftpput -A -u <usname> -p <pwd> <000.000.000.00> /remote_dir *

anandv.txt:                                             21.72 kB   10.79 kB/s
arorapoly.txt:                                          10.90 kB    5.37 kB/s
asian.txt:                                               2.85 kB    2.99 kB/s
asr4.txt:                                                4.62 kB    3.58 kB/s
avihar.txt:                                             25.67 kB    6.17 kB/s
beawer.txt:                                              3.97 kB    3.12 kB/s
bhatinda4.txt:                                           9.66 kB    5.43 kB/s
bikaner5.txt:                                            9.52 kB    5.13 kB/s
crpark.txt:                                             13.31 kB    7.49 kB/s
defence.txt:                                            24.14 kB   12.53 kB/s
dlf1.txt:                                                6.99 kB    4.62 kB/s
durgap.txt:                                             19.30 kB    9.75 kB/s
dwarka3.txt:                                            11.82 kB    7.38 kB/s
dwarka6.txt:                                           255.35 kB   65.93 kB/s
farid21.txt:                                             2.52 kB    2.62 kB/s
faridabad.txt:                                           5.20 kB    3.83 kB/s
faridkot2.txt:                                           8.95 kB    5.78 kB/s
farukh.txt:                                             12.12 kB    6.71 kB/s
ganga4.txt:                                              4.47 kB    3.45 kB/s
ggn2.txt:                                              145.24 kB   44.80 kB/s
ggncolumb.txt:                                           8.37 kB    6.55 kB/s
gnoida.txt:                                             10.67 kB    2.98 kB/s
greenp.txt:                                             20.84 kB    9.88 kB/s
hamirpur.txt:                                            2.05 kB    1.87 kB/s
hpur3.txt:                                              11.61 kB    6.11 kB/s
indira2.txt:                                            51.92 kB   22.35 kB/s
indore2.txt:                                             6.19 kB    1.74 kB/s
jabal4.txt:                                              9.60 kB    2.69 kB/s
jagraon.txt:                                            17.64 kB    9.22 kB/s
jangpurab.txt:                                          15.10 kB    8.65 kB/s
jlndr1.txt:                                              4.49 kB    3.21 kB/s
kakinada.txt:                      ETA:   0:00    4.00/ 10.52 kB  799.84 kB/s

ncftp is capable to upload one file at a time here. Could you help me to understand how it can make a thread.

Regards.

Oh, you want to open dozens or hundreds of network connections simultaneously. Not usually a good idea. Too many connections can overwhelm a router, and the host you're uploading to might even consider it an attack.

Do you have ssh access to the machine? Can you upload an archive of some sort and unpack it there? Uploading one big file would avoid some overhead.

Can You pack the files? Simple tar with no compression should be sufficient. Than You would have to send one file instead of "many".
Besides, most ftp configurations doesn't allow more that 2-5 connections for the same user/IP/whatever.

Thanks both Sulti and Corona,

No, I don't wat want to open tons of connections, but 2-3 threads would definately be ok. in my script a while loop continusly monitor the source forder. When a file arrives in the folder the program hand ot over to ncftpput. So any mechanism to open at least 2-3 thread would be ok any how.

Any comments please ?

Regards

---------- Post updated at 05:04 PM ---------- Previous update was at 12:33 PM ----------

Is there any body else to know the solution ?

Regards

You could invoke ncftpput as a background process and start multiple sessions within your while-loop.

This'd be much easier in anything but c-shell.

Hi.
I agree with previous suggestions for combining the files, and then sending a single file.

However, if you don't wish to do that, then for one alternate solution, see GNU Parallel - GNU Project - Free Software Foundation :

       GNU parallel is a shell tool for executing jobs in parallel using one
       or more computers. A job is can be a single command or a small script
       that has to be run for each of the lines in the input. The typical
       input is a list of files, a list of hosts, a list of users, a list of
       URLs, or a list of tables. A job can also be a command that reads from
       a pipe. GNU parallel can then split the input and pipe it into commands
       in parallel.

       If you use xargs and tee today you will find GNU parallel very easy to
       use as GNU parallel is written to have the same options as xargs. If
       you write loops in shell, you will find GNU parallel may be able to
       replace most of the loops and make them run faster by running several
       jobs in parallel.

another is Parallel Distributed Shell | Download Parallel Distributed Shell software for free at SourceForge.net :

       pdsh is a variant of the rsh(1) command. Unlike rsh(1), which runs
       commands on a single remote host, pdsh can run multiple remote commands
       in parallel. pdsh uses a "sliding window" (or fanout) of threads to
       conserve resources on the initiating host while allowing some
       connections to time out.

Best wishes ... cheers, drl

Hi CRL,

Thanks for your reply. I have actually knew both the programs, but they will open a new connection for every instance of the ncftp. I am actually looking for some solution in Unix like filezilla works on windows i.e. upload multiple files with a single connection. Please see if you can find something.

Regards

You can download a binary (or compile it yourself).
But I don't think FileZilla supports multithreaded operations (lftp seems to support parallel put/get though).