Is the format of (P)SFTP's dir/ls standard?
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 serv开发者_运维技巧er here to test against.
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.
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.
精彩评论