0

I have a simple FTP script to download files from a directory, but when I run it, it just goes out to lunch and never comes back.

ftp> ftp -n -s:"download.txt" ftp.mysite.com

download.txt:

user ******* ********
ascii
cd /remoteFiles
prompt off
mget *
quit

Even if I try to do a simple ls command, it won't list files:

user ******* ********
cd /remoteFiles
ls
quit

result:

---> PORT 192,168,1,85,239,192
200 Command okay.
---> NLST
150 Opening ASCII mode data connection for file list.
Aborting any active data connections...
425 Can't open data connection.

What am I missing here?

Eric Belair
  • 10,574
  • 13
  • 75
  • 116
  • 1
    FTP uses two communication channels: __1.__ The command/control channel established by the FTP client with connection to the FTP server. __2.__ The data channel established by the FTP server with a connection to the FTP client. The establishment of the data channel is an incoming connection action which is usually blocked nowadays by firewalls on any PC. You would need to add a rule to the firewall to allow an incoming channel connection attempt from this FTP server or use the passive FTP mode on which the FTP client establishes also the data channel if the FTP server supports that. – Mofi Apr 26 '23 at 19:15
  • See also: [How to use passive FTP mode in Windows command prompt?](https://stackoverflow.com/questions/18643542/how-to-use-passive-ftp-mode-in-windows-command-prompt) I recommend to read also the Wikipedia article about [File Transfer Protocol](https://en.wikipedia.org/wiki/File_Transfer_Protocol), especially the section about __Protocol overview__. – Mofi Apr 26 '23 at 19:16
  • @Mofi seems like WinSCP might be the best option here, since I don’t have control over the FTP server. thanks – Eric Belair Apr 27 '23 at 13:52

0 Answers0