1

I tried getting a file off of my ftp server with a batch file. Here is what happens:

ftp> open files.000webhost.com 21
Connected to us-east-1.route-1000.000webhost.awex.io.
220 ProFTPD Server (000webhost.com) [::ffff:145.14.145.124]
500 OPTS UTF8 not understood
User (us-east-1.route-1000.000webhost.awex.io:(none)):
331 User ***** OK. Password required

230-Your bandwidth usage is restricted
230 OK. Current restricted directory is /
ftp> lcd C:\Users\micah\Desktop\MiniventureLauncher\Game
Local directory now C:\Users\micah\Desktop\MiniventureLauncher\Game.
ftp> cd public_html
250 OK. Current directory is /public_html
ftp> binary
200 TYPE is now 8-bit binary
ftp> recv miniventure.jar
200 PORT command successful
150-Connecting to port 50186
150 13336.1 kbytes to download

Then it just stops. Here's the code in my batch file:

@Echo Off
Set _FTPServerName=files.000webhost.com 21
Set _UserName=*****
Set _Password=*****
Set _LocalFolder=C:\Users\micah\Desktop\MiniventureLauncher\Game
Set _RemoteFolder=public_html
Set _Filename=miniventure.jar
Set _ScriptFile=transfer
:: Create script
 >"%_ScriptFile%" Echo open %_FTPServerName%
>>"%_ScriptFile%" Echo %_UserName%
>>"%_ScriptFile%" Echo %_Password%
>>"%_ScriptFile%" Echo lcd %_LocalFolder%
>>"%_ScriptFile%" Echo cd %_RemoteFolder%
>>"%_ScriptFile%" Echo binary
>>"%_ScriptFile%" Echo recv %_Filename%
>>"%_ScriptFile%" Echo quit
:: Run script
ftp -s:"%_ScriptFile%"
Del "%_ScriptFile%"

It connects to the server, but it won't download the file.

6
  • Possible duplicate of Command-line FTP function does not work Apr 3, 2018 at 13:10
  • It does say "230-Your bandwidth usage is restricted". Is the file large? Maybe you are limited to a certain limit per session? Does this work in a client like filezilla? "150-Connecting to port 50186" is this port open? Try running ftp with -d ftp -d -s:"%_ScriptFile%" for more debug information.
    – mt025
    Apr 3, 2018 at 17:33
  • I hope the username and password in the file aren't you actual username/password. If they are, please change your password asap (at your provider, hiding it here won't help). Apr 3, 2018 at 19:26
  • 1
    Als, what happens if you run the commands manually?, Try adding 'hash' before transferring the file. Apr 3, 2018 at 19:31
  • djsmiley2k, I tried running it from the command prompt and the same results came up Apr 3, 2018 at 22:49

1 Answer 1

0

As @martin-prikryl suggests in the comments, this is almost certainly a Windows firewall issue.

While Windows ftp can connect to a remote host without special permission, to download files, incoming remote transfers need to be explicitly allowed through the Windows firewall.

Allowing Incoming Transfers

If there are no Windows firewall rules for Windows ftp, when you run it with the recv command, you should be prompted to add Incoming rules to the Windows firewall automatically. The box marked Private networks [...] should be checked by default. Press the Allow access button to add the appropriate rules to your Windows firewall.

ex. Allow downloads via Windows ftp.exe

Add Windows Firewall Rule - Screenshot

You shouldn't need to check the box marked Public networks [...] unless you intend to use Windows ftp away from home. You'll need to be an administrator to adjust firewall rules.

Note that, unfortunately, this will not allow the current download to continue. You will need to abort the current operation (usually with Ctrl + C) and try again.

No Firewall Pop-up Is Displayed

If the transfer hangs and no firewall rules pop-up is displayed, this most likely means that there are already existing rules in the Windows firewall for Windows ftp (these are added even if you initially press Cancel in the dialog box above). Furthermore, it is likely these rules are set to block any incoming connections (indicated by circle icons with slashes through them).

ex. Windows ftp.exe blocked by the Windows firewall

ftp.exe Blocked By The Windows Firewall - Screenshot

To change this:

  1. Open Control Panel\System and Security\Windows Firewall and click the link marked Advanced settings on the left hand side.

  2. In the Windows Firewall with Advanced Security dialog (shown above), click the Inbound Rules link on the left and wait for the primary pane to populate. Look for the two rules marked File Transfer Program. You can click on the Name category heading to sort items alphabetically, as needed.

  3. For each rule, right-click it and select Properties. Under the General tab, change the Action from Block the connection to Allow the connection. Press OK at the bottom of the dialog when finished.

    ex. Updating Windows firewall rules for Windows ftp.exe

    Unblock Windows ftp.exe Firewall Rule - Screenshot

  4. If done correctly, the cirles-with-slashes icons should be replaced with green check marks.

    ex. Windows firewall rules for Windows ftp.exe - green check marks

    Windows ftp.exe Firewall Rule Green Check Marks - Screenshot


Creating Your Own Rules

On the off chance you wish to manually add (create) these rules yourself, proceed through Steps 1 and 2, except click New rule... on the right-hand side after selecting Inbound Rules.

Make one rule for TCP connections and one rule for UDP connections (protocol options are listed under the Protocols and Ports tab). Make sure that All Ports are allowed. Adjust the Scope tab properties (usually set to Any IP Address ) and the Advanced tab Profiles (ususally just Private) as needed.

Lastly, under the Programs and Services tab, put e.g. C:\windows\system32\ftp.exe as the program path (if in doubt, you can use where ftp from a command prompt to display the proper path).


1
  • 1
    Nice answer, but why don't you post it to the original question, and vote for this one to be closed as duplicate? Apr 16, 2018 at 7:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .