Typically,
ftp will issue you an error if there is a problem with the
ftp command execution itself, but I presume you want error handling for the actual file transfers. That gives you a slight problem, but if you can put on a
-v flag, then hopefully the output will be studded with three digit response codes.
Those below 400 are normal successful execution, those 400 & above are errors.
If you capture all the output into a file, you can search that file for errors. These will be lines starting 400 or higher, along with anything saying any of the following
- Not connected
- cannot access
- not found
- No such file
However, you will have to exclude the success output from a good transfer that just happens to have a few hundred bytes, e.g.:-
499 bytes sent is not an error.
The way we do it is to have a list of questionable items to search for and then a list of exclusions from that list. We pass the output through both tests and then we can work out whether we've done it or not. Probably best to move one file at a time too if you can. If you have lots to move, just call them in a loop and you immediately have more information about which one has failed.
Have a go an let us know how you get on.
I hope that this helps,
Robin
Liverpool/Blackburn
UK