0

Every day I need to upload automatically about 100 images with a total size of 4MB.

I've used ncfttput and FTP via command line, but sometimes the upload of one image gets stuck with a Connecting to port message, and so it stops the FTP-upload of the others.

I'm currently using this script:

#!/bin/bash
cd /home/giacomo/WRF/DOMAINS/puglia/postprd
ftp -i -n -v <<EOF
open "server"
user "username" "password"
binary
cd /www.example.org/wrf
mput 2mTemp*.gif
quit
EOF

sleep 10

ftp -i -n -v <<EOF
open "server"
user "username" "password"
binary
cd /www.example.org/wrf
mput 850mbRH*.gif
quit
EOF
etc...

How could I set a timeout with a consequential retry? Or is there a non-command line method to manage all of this automatically (sync my local folder with my remote folder and take care of any errors)?

5
  • Do you have rsync and/or ssh access? If not, you can use the timeout(1) command to limit the runtime of any given ftp attempt. Is there any reason you are reconnecting for each image? Is it because the connection may hang on any given image?
    – zackse
    Commented Aug 21, 2015 at 21:16
  • You could also use ls after the mput and compare the remote listing with a local one, and repeat the ftp if there are differences.
    – AFH
    Commented Aug 22, 2015 at 13:17
  • @zackse, yes, I'm not uploading each *.gif file "all-in-one", but I have divided them in multiple groups because it may hang on any image among the gif files.
    – Giacomo
    Commented Aug 22, 2015 at 13:58
  • @AFH, I could not use ls in mput since it may get stuck in any image included in mput xxxx*.gif Anyway I may have solved partially, since I'm using now the passive mode and, unless my upload band is too low, it does not hang anymore. I will keep you updated
    – Giacomo
    Commented Aug 22, 2015 at 14:00
  • I've often found passive mode more reliable. I hope this sorts out your problem. I generally use the FireFTP add-on for Firefox when I want to make ftp transfers: it is very reliable, and retries when necessary, but it's not suitable for automation. I make regular small automated transfers with the standard Ubuntu and Windows command-line ftp: my number and size of files are much smaller than yours, and I have had few problems (I use passive mode).
    – AFH
    Commented Aug 22, 2015 at 16:47

1 Answer 1

1

I have resolved by using the FTP passive mode. Here is the new FTP command:

#!/bin/bash
cd /home/giacomo/WRF/DOMAINS/puglia/postprd
ftp -i -n -v <<EOF
open "server"
user "username" "password"
binary
passive
cd /www.example.org/wrf
mput 2mTemp*.gif
quit
EOF

sleep 10

ftp -i -n -v <<EOF
open "server"
user "username" "password"
binary
passive
cd /www.example.org/wrf
mput 850mbRH*.gif
quit
EOF
etc...
2
  • 1
    Thanks for closing the loop on your question. For the benefit of others with a similar issue, can you expand your answer to describe what you did?
    – fixer1234
    Commented Aug 25, 2015 at 22:55
  • Added the word "passive" to my FTP command list
    – Giacomo
    Commented Aug 26, 2015 at 10:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .