Even though there are several ways to accomplish getting files from an FTP site via scripted DOS commands, we at roguehelpdesk.com generally recommend going with an official how-to from the source which is Microsoft in this case. Microsoft recommends using 2 files. The first one is a text file that holds the FTP information and the other is the DOS/BATCH script that runs the FTP command. So once you run your FTP script, it will run the FTP command and process the FTP information file “test.src”.
EXAMPLE from http://support.microsoft.com/kb/96269
1st file = “test.scr”
open 11.11.11.11
username
password
get file1
quit
2nd file = “sendftp.bat”
ftp -s:test.scr
Here’s another way to accomplish this with only one file. The only caveat is that the FTP information, including the username and password are within that one DOS/batch script.
@ECHO OFF
REM Generate FTP info for temp.txt
echo open ftp.domain.com> temp.txt
echo username>> temp.txt
echo password>> temp.txt
echo binary>> temp.txt
echo prompt>> temp.txt
echo lcd P:\_FTP\SENT>> temp.txt
echo ls>> temp.txt
echo mget *.*>> temp.txt
echo quit>> temp.txt
REM Launch FTP via DOS and process FTP info from text file
ftp -s:temp.txt
REM Temp file clean up
del temp.txt
Since we’re sending multiple pages, we used the “mput” command. I believe the “m” stands for “multiple”. When using the mput command, we at roguehelpdesk.com recommend using the “prompt” command prior to mput so it doesn’t prompt each time it tries to send/upload a file.
SOME COMMON ERRORS:
“500 PORT/EPRT (Active Mode/Extended Active Mode) is not supported. Use PASV/EPSV instead”
You can try the “passive” or “quote pasv” command but in many cases, this error usually means there is something blocking it like a firewall or antivirus.
REFERENCES/LINKS:
http://support.microsoft.com/kb/96269
9 Responses to “How do I write a DOS script to get files from an FTP site?”
I’ve been through this!
Why don’t we give this a try?
I have no idea what you have said
Hello there, You’ve done a great job. I
definitely digg it and individually suggest to my friends.
I am sure they will be benefited from this website.
I’ve learn a few just right stuff here. Certainly value bookmarking for revisiting.
I wonder how so much effort you set to make such a magnificent informative web site.
You are a very bright person!
I do not even know how I ended up here, but I thought this post was good. I don’t know who you are but certainly you are going to a famous blogger if you aren’t already 😉 Cheers!
Merely wanna say that this is extremely helpful, Thanks for taking your time to write this.
Always a large fan of linking to bloggers that I enjoy but really don’t get lots of link really like from.