5

I'm putting together something to download some files over SFTP. I'm using PuTTY's psftp.exe command.

When I do a dir/ls in PSFTP, is the format of the output standardized, either by SFTP or by PSFTP itself? Or is it just whatever free-form text the server happens to send in response?

I ask because I believe in FTP (way back when!), it was not at all standardized, and I only have one SFTP server here to test against.

2 Answers 2

2

Unlike FTP (which used text LIST output), the SFTP protocol is based on binary structures, so Putty is doing all the formatting. Specifically, it uses the SSH_FXP_READDIR command to read directory entries, which are returned in the format specified by SSH_FXP_NAME.

Ideally you would use an API, rather than psftp. But if you choose to parse the text, you have PuTTY and only PuTTY to worry about.

My mistake. The newer draft I looked at does not have such a text longname field. However, older versions do.

1
  • 2
    This is NOT true. In SFTP-3 (that PSFTP uses) and older, the SSH_FXP_NAME contains longname field that includes formatted listing entry. PSFTP prints that. So the format WILL differ with server. Apr 25, 2014 at 10:43
2

Matthew, the local client may choose to show the information on the longname slots from the SSH_FXP_NAME response instead of generating it locally from the filename and attrs slots.

Whit out looking at how psftp does it internally, you can not be completely sure that its format will not change when connecting to a different server.

1
  • 1
    This is correct answer. PSFTP prints the longname field of SSH_FXP_NAME coming from the server. So format WILL definitely differ with server. Apr 25, 2014 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.