Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy a file from FTP and save it to my local system. I want to run this through batch file. I am trying this for a week. But I couldn't find the solution. Anyone help me please....

This is my actual work


Want to copy a file named "Friday.bat" from ftp://172.16.3.132 (with username and password) So i use the below codings:

@echo off
@ftp -i -s:"%~f0"&GOTO:EOF
open 172.16.3.132
mmftp
((((pasword entered here)))))
binary
get Friday.bat 
pause

Result:


ftp> @echo off
ftp> @ftp -i -s:"%~f0"&GOTO:EOF
Invalid command.
ftp> open 172.16.3.132
Connected to 172.16.3.132.
220 Welcome to ABL FTP service.
User (172.16.3.132:(none)):
331 Please specify the password.

230 Login successful.
ftp> binary
200 Switching to Binary mode.
ftp> get Friday.bat
200 PORT command successful. Consider using PASV.
550 Failed to open file.
ftp> pause

Finally, a file named Friday.bat is copied to my local system with 0 bytes and I am not able to open it

share|improve this question
add comment

closed as off topic by TFM, Nifle, ChrisF, Synetech, HackToHell Nov 18 '12 at 14:53

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

4 Answers

I would check that you are either running command prompt as an elevated user, or launching this command from a path where you have permission to write.

If this doesn't do anything, the most likely cause, and what I believe is ahppening is that your firewall is stopping you from downloading the file. Try disabling it and try again.

share|improve this answer
add comment

Have you tried using PASV (passive mode) as the error suggests? Passive mode helps the FTP client get past firewalls and NAT devices (routers) much better as active mode tries to open a port to you to send data (which will fail if you are behind a router) while with passive mode you are actually sucking the data down.

It's just as easy to enable passive mode as binary, and you should do it like this:

@echo off
@ftp -i -s:"%~f0"&GOTO:EOF
open 172.16.3.132
mmftp
((((pasword entered here)))))
binary
passive
get Friday.bat 
pause
share|improve this answer
add comment

Are you opposed to using a 3rd party tool like wget.exe, a Unix for Windows tool? (Download here or here)

To make it easier you can still use a script, with fast downloads of a single file or an entire site by using one line of code.

wget.exe --ftp-user=USERNAME --ftp-password=PASSWORD -Ofriday.bat 172.16.3.132

If it's not in the root directory, add wget.exe -r for a recursive scan of the site for a file. You can add the recursion level or span host.

Just food for thought: If you don't have to use ftp.exe, firewalls and other security software does not have any issues with passive – wget does all the work porting.

share|improve this answer
add comment

Leaning on this answer I think that you have either authenticated yourself incorrectly, or lack the permissions to read the file.

Apart from that, I'd recommend you to use expect to automate interactive applications. This tool works really well. Consider reading this chapter to get familiar with it. If that's not enough, I assure you that this is an old (stable) tool with many, many examples on the net.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.