Ftp – Why is the FTP output file blank

ftp

From the Windows command prompt, I have FTPd to a Windows web server. I can get a file, and I can see a directory listing with dir, but I want to save that list locally.

I tried dir > c:\somefile.txt, and the file is created, but it's blank. Same thing if I do ls > c:\somefile.txt.

The result is the same when I FTP from a Linux box.

FTP sends back the following:

200 PORT command successful
150 Opening ASCII mode data connection for /bin/ls
226 Transfer complete

Best Answer

This is probably because FTP.exe take control over the shell. So redirections, that are handled by the cmd.exe have no effect.

What you can do, is use the -s:filename option and redirect the whole ftp output to a file. It will contain more then you want, but you can take care of that later.

Or, maybe, look for other ftp clients that have this functionality ( I am not aware of any).