SFTP Problem and Solution

  • I've been using PuTTY's PSFTP program to do an SFTP transfer from two hosts. The file format is the same (the contents are different) and the command line options are the same (except for password and hostname stuff).

    The problem that I ran in to was kind of interesting. The file from Host A was just fine, but DTS had problems with the file from Host B and rejected it. Something looked weird, so finally I opened the file in TextPad.

    If you just opened the file regularly, it looked just fine. But when you opened it in Binary, the problem was obvious: every line ended in a Line Feed without a Carriage Return. The file from Host A ended in CR/LF (hex 0D 0A) and DTS had no problems processing it.

    FTP/SFTP programs typically have a command switch to specify whether to do a binary or ASCII transfer, PSFTP only does binary. Some also have options to force CR/LF at the end of lines, PSFTP does not.

    The default behavior of Windows is to terminate lines in CR/LF. In Linux and Mac environments, one ends in CR only, the other in LF only, but I don't remember which is which. This could be the source of the problem, but neither vendor will tell me what their equipment is, so I don't know.

    My solution? I switched to WinSCP. It has the functionality of PSFTP, pulls down the file from Host B with CR/LF, and is also free and available at Sourceforge. It also has a GUI interface like Norton Commander and can directly tie in to Windows Explorer, but I'm only interested in the command line flavor.

    I used PSFTP because I've used PuTTY for ages and trusted them, unfortunately it looks like there's some occasional odd behavior in PSFTP and I can't have that with a unattended production system. I've sent them a bug report, hopefully they'll get it fixed.

    Just wanted to inform the community at large that if you're having weird FTP problems, you might want to look at your file through a hex dump to see what's really going on.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • *nix files end in a LF only.

    Just an FYI.

  • Thanks, Lynn! I can never keep 'em straight. 😀

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • Not a problem. I dealt with files from a Solaris box for years so it is sort of ingrained now. I didn't know that Mac used the CR only to end files.

  • That was my understanding, but that could be old (pre-OS X) or inaccurate. I've always wanted to work with Solaris, but I've never had the gumption to really buckle down and learn Unix.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • I don't admit to Solaris often. The systems are expensive (even if reliable) and could easily be replaced with commodity servers running linux for a lot less.

    It did give me the opportunity to learn csh, ksh, and a couple of others I can't remember. But then I remember very little about any of them now. It's been over 4 years since I used any of them.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply