Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FTP List format

Tags:

ftp

I'm writing an embedded ftp server, and I cannot get the listing format correctly. The server works completely, only programs like FileZilla cannot interpret the listing format. Here's a sample listing:

-rwxr--r--  1   owner   group 640   1970 01 01  test
-rwxr--r--  1   owner   group 13440 1970 01 01  test.html
-rwxr--r--  1   owner   group 512   1970 01 01  test2.txt

Which is basically:

permissions[tab]number?[tab]owner[tab]group[tab]filesize[tab]date[tab]filename 

What am I doing wrong?

Thanks, Yvan

like image 989
friedkiwi Avatar asked Mar 14 '10 17:03

friedkiwi


People also ask

What is FTP file format?

File transfer protocol (FTP) is a way to download, upload, and transfer files from one location to another on the Internet and between computer systems. FTP enables the transfer of files back and forth between computers or through the cloud. Users require an Internet connection in order to execute FTP transfers.

How do I list files in an FTP folder?

dir -R = Lists all files in current directory and sub directories. dir -S = Lists files in bare format in alphabetic order. Exits from FTP. Get file from the remote computer.

What is FTP command list?

LIST FTP command. The LIST command is issued to transfer information about files on the server through a previously established data connection. When no argument is provided with the LIST command, the server will send information on the files in the current working directory.

Which format is used by FTP server?

FTP (and FTPS) data type of transferred files can be ASCII or binary. ASCII type is used to transfer text files. The line-ending format of text files vary on different platforms.


1 Answers

As others have already mentioned, you need to use spaces instead of tabs. Here's a sprintf from another embedded FTP server that should work:

sprintf(line, "%s   1 %-10s %-10s %10lu Jan  1  1980 %s\r\n",
    permstr, username, username,
    length,
    filename);

permstr is set to a string like "-rw-rw-rw-".

As for date formats, these two should work, with the top used if the date is more than 6 months old:

if (dfmt)
    sprintf(buf, "%3.3s %2d  %04d", month_name, month_num, year);
else
    sprintf(buf, "%3.3s %2d %02d:%02d", month_name, month_num, hour, minute);
like image 83
tomlogic Avatar answered Nov 18 '22 21:11

tomlogic