views:

36

answers:

2

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 Putty, is the format of the output standardized, either by SFTP or by Putty 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.

+3  A: 

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.

Matthew Flaschen
+1  A: 

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.

salva