Re: Detecting sftp batch upload errors

From: Jim Colten (jim@colten.net)
Date: 02/04/03

  • Next message: Bill Lewis Clark: "Re: PermitRootLogin=yes versus su"
    From: Jim Colten <jim@colten.net>
    Date: Tue, 04 Feb 2003 04:46:12 GMT
    
    

    you might want to consider using Expect to spawn an sftp session and
    feed it commands while it watches the responnses for the expected vs
    unexpected results from each command.

    Mopar Quoplic wrote:
    >
    > I am trying to write a script that will handle automated file
    > transfers to and from an sftp server, but am having trouble detecting
    > upload errors. What I am trying to do is this:
    >
    > sftp -oIdentityFile=id_dsa -b batchfile user@server
    >
    > ...where batch file contains:
    >
    > put /my/local/file /my/remote/file
    > bye
    >
    > When the upload is successful, everything is fine. If the upload fails
    > (because the target directory doesn't exist, or if user doesn't have
    > write access to the target directory) sftp does not fail as I would
    > expect. The man page says that when using the -b option, sftp will
    > "abort" if one of a number of commands fails, including "put." I would
    > expect that "abort" means exit with an error status that a script can
    > detect, but this doesn't appear to be the case. If I add a line with
    > "ls" after the "put" the "ls" is executed regardless of whether the
    > "put" was successful indicating that nothing other than the "put"
    > aborted, and in either case, sftp does not return an error status.
    >
    > The same happens when using '-oBatchMode <<' instead of '-b batchfile'
    > (not surprisingly):
    >
    > sftp -oIdentityFile=id_dsa -oBatchMode=yes user@server <<FOO
    > > put /my/local/file /my/remote/file
    > > bye
    > > FOO
    >
    > Am I missing something obvious? Is there a better way to upload files
    > using sftp? In the past I have used scp for scripted file transfers
    > (and I saw this suggestion offered elsewhere in this group), but in
    > this case the target server only allows sftp access. At the moment,
    > the only ways around this that I can see are parsing the output to
    > catch error strings, or putting in a "ls" and parsing the directory
    > list output to see if the file I uploaded is where I want it to be.
    > Neither of those seem like robust solutions. (What if a file with the
    > same name was there before - do I then try to parse the file's date
    > along with the file name? What if I'm not catching every possible
    > error string when I'm parsing the output? etc?)
    >
    > I'd appreciate any help...
    >
    > Thanks!



    Relevant Pages

    • Detecting sftp batch upload errors
      ... I am trying to write a script that will handle automated file ... transfers to and from an sftp server, ... When the upload is successful, ...
      (comp.security.ssh)
    • Re: Good sftp server?
      ... FDL on the files that I upload to convert it into STREAM_LF format. ... > it except for the sftp server, ...
      (comp.os.vms)
    • Re: Several users need to work in the same directory
      ... upload several new files using sftp, and I am wondering if they really ... have to logon again using ssh and then manually set the execution bit ... sftp doesn't do well with permission bits. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: Strategy or A factory with Template Method
      ... if (sftp) {// upload via SFTP} else if (scp) else } ... What the author of the blog says to use Strategy Design Pattern to ...
      (comp.object)
    • Re: In the market for a secure replacement for FTPD
      ... SFTP isn't ... > realy ftp, but rather a frontend to ssh, accepting ftp-like commands. ... > autentication and allows for encription of a connection as well. ...
      (comp.os.linux.misc)

  • Quantcast