Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to copy a file from FTP and paste it to my local system. I want to run this through a 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 coding:

@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, but it will not open.

share|improve this question

migrated from stackoverflow.com Nov 21 '11 at 12:48

This question came from our site for professional and enthusiast programmers.

    
Voting to migrate question to Server Fault –  CharlesB Nov 20 '11 at 13:25
    
What kind of firewall(s) do you have between the FTP server and client? Generally, how are they configured? –  Chris S Nov 21 '11 at 13:22
    
I am not using any firewall –  Phillips Nov 30 '11 at 13:54
add comment

3 Answers

Make sure you can download the file manually with your favorite brand of FTP client. If it doesn't work, the problem seems to be on the server side: the FTP Server cannot access the file, for whatever reason (permissions?). If it does, make sure the process executing your batch file has write permission in the current directory, or better, do change the directory prior to downloading.

Pro's would create a temporary directory and and process the file there (but be sure to lock down this directory and clean up afterwards).

share|improve this answer
add comment

ftp doesn't like line two... is it necessary?

Error 550 is thrown if either the file doesn't exist, or you do not have correct permissions to the file. Make sure you have global read rights to the file, or that you use the user command to login with a known local user to the remote machine that has access rights to the file. Ensure these conditions are correct.

That should fix your problem.

share|improve this answer
add comment

I would recommend trying WinSCP which has some nice scripting features.

http://winscp.net/eng/index.php

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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