Error checking in sftp

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi folks.

I need to automate a few sftp sessions, which is easy enough, either
with a batch file or via stdin.

_But_ what worries me is that sftp does returns with an exitcode equal
to zero almost no matter what fails during the transfer.

What I'm doing with ftp is to check the error messages based on the
numbering of error codes which ftp uses (300, 400, and 500 series are
(with a few exceptions) errors). I.E. I'm parsing the sysout.

With sftp it's a different story. There seems to be no standard error
messages between serveres, and provoking all types of errors will be to
time consuming and to insecure.

I am aware that sftp will abort on cd, rm and get if you use a batch
file. But that's just not good enough. I need to trap any errors.

What I've done is that I do only one file transfer at a time, and I
compare the filesize on the local and remote file after the transfer has

What have other people done?

Stein Arne

Re: Error checking in sftp

Quoted text here. Click to load it

It might be simplest to write an entire file transfer protocol
and implementation and just run it over SSH.   I do this in a couple
of places.   My retrieval of significant logs fragments from my
webserver is a protocol similar to POP3 for instance.   What do
you need beside a single connection with both command and data modes
and some keeping of state at the ends ?

Elvis Notargiacomo  master AT barefaced DOT cheek /
    My energy-saving light bulb caught fire.  Now I know
    the NSA are beaming microwaves at my flat.

Re: Error checking in sftp

Quoted text here. Click to load it

Writing a new software is a bit out of reach for me.
Besides, this is going to run on a variety of hosts and _against_ a
variety of hosts (both Unix of various types and Windows(...)).

This means that I in some cases are restricted to _only_ sftp.

Stein Arne

Site Timeline