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

link|improve this question
feedback

3 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.

link|improve this answer
feedback

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
link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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