FTP ls Command – Returns Empty File

ftp

I am trying to retrieve a list of files from a remote FTP server using the ls command. When just executing ls by itself in the command line, it lists the files. When adding a filename to the command, it returns an empty file.

My code works perfectly on several other ftp servers (likely different server config). Not sure what is going wrong.

ftp> Packet tracing On .
ftp> trace on
Connected to ************.
OPEN ************
220 ************ FTP server ready.
User (*****************): 
331 Password required for ********.
230 User ********* logged in.  Access restrictions apply.
ftp> CD incoming
250 CWD command successful.
ftp> Local directory now C:\csrkb\etl\files\incoming\TASK0460\txt\FTP_OBJ_LIST.
ftp> LCD C:\csrkb\etl\files\incoming\TASK0460\txt\FTP_OBJ_LIST
ftp> ls - FTP_OBJECT_LIST.TXT
200 PORT command successful.
150 Opening ASCII mode data connection for /bin/ls.
226 Transfer complete.
ftp> BYE
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 12603 bytes in 2 transfers.
221-Thank you for using the FTP service on ftp-out.
221 Goodbye.

Best Answer

Why are you using the dash after ls? The remote server is returning an empty list. I would search in the FTP server logs. Make also a network capture with Wireshark. If you have a L7 firewall you should do a capture on the server and compare the two captures.