tags:

views:

164

answers:

3

I have a bash script to upload some files to my webserver. The problem is that it seems to assume that when they get to the webserver they are missing the final 4kb of the file.

On my computer the file is listed as 8kb (rounded up because blocks are 4kb) yet only 4kb are uploaded.

Here's the funny/confusing part, this only affects the last file uploaded as if it's closing the session early.

Is this a known issue? The man page has nothing that I could see.

Below is a copy of the script (minus login details of course):

ftp -in <ftp.host> <<EOF
quote USER <username>
quote PASS <password>

binary

put file1.xml
put file2.xml
put file3.xml
put file4.xml
put file5.xml
put file6.xml
put file7.xml
put file8.xml
put file9.xml
put file0.xml
quit
EOF

A link to one of the example files is http://woarl.com/xml/f8d9b3b981a356efc1ecbb705b369c9e.xml

A: 

Sounds like your FTP program is reading "quit" immediately after starting the "put" but before letting it finish.

Probably you want to find a different command other than quit which waits for uploads to finish. Perhaps "BYE" or some such.

SoapBox
Nope, no difference on this one, though it did break it at a different point.
Teifion
+3  A: 

The last put command is probably still transmitting data (over passive connection) when the client exits. BYE is just an alias for quit so it won't help, but maybe you could try adding some other command between the put and quit, for example ls.

Or if no firewalls forbid, setting up the session the active mode would most likely force the client to wait for the last put to complete before issuing the quit.

Timo Metsälä
Excellent idea. I was going to put an extra put (for a file that's not needed) but figured that'd be a messy way to do it, the ls is not perfect but still better.
Teifion
+2  A: 

Not what you're asking, of course, but for these sorts of things I like to install the ncftp utilities. That includes ncftpput and ncftpbatch for batching up a bunch of ftp commands and executing them.

Paul Tomblin