Solved

Batch file to download a file from FTP server

Posted on 2015-02-03
6
401 Views
Last Modified: 2015-02-11
Hi There,
I need to create a batch file to download a file in a particular folder from the FTp server to a folder on the local drive

Example  this is what I have
my ftp server name ftp.mydomain.com
user name     test
password       testp

so on the FTP server on a folder called Testfolder, I need to download all the files in this folder to the local C drive
in C:\temp   folder

I will appreciate if somebody can give me the line that will go on the batch file. I tried few never worked.
0
Comment
Question by:Sivasan
  • 3
  • 3
6 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 40587225
It works best to use a script file with ftp from the batch file. That is two files, but much easier.

Your batch should look something like this
cd c:\Temp
ftp -n -s:C:\yourscript.src ipOfFTPServer

The script should contain something like:
user test testp
cd /TestFolder
binary
get somefilename
close
bye

Open in new window


Obviously you should change some things in the ftp line as needed, etc.
0
 

Author Comment

by:Sivasan
ID: 40589050
Hi SStory,
Thank you so much, it work, it downloads the file, but when I look at the size of the file it says 0 bytes, so I'm wondering if it completly downloaded the file. Is there a way I can make sure connection is open till file is downloaded completely?
thanks
0
 
LVL 25

Expert Comment

by:SStory
ID: 40594182
Basic ftp commands can be found by using Google. Here are two examples:
http://www.nsftools.com/tips/MSFTP.htm
http://www.cs.colostate.edu/helpdocs/ftp.html

It sounds like it may be timing out on your before it finishes or there is some other problem.  I know of no other way to tell it to 'stay open'.  Mine just works when I do that.

I see a trace command that _MIGHT_ help you diagnose it.
0
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

Author Comment

by:Sivasan
ID: 40598967
Adding the trace command didn't bring up any trace, not sure if I'm using it right.
thanks
0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 40601320
I'm sorry, but what I have given you just works for me. You might consider downloading Wireshark or something and examining the packet traffic to see if you can determine what is going on, but I suspect the connection is timing out on your. That could be a setting on the ftp server. I'm not sure what else to tell you using Microsoft's ftp command-line app.  There are plenty of FTP programs. Many of them have scripting capabilities.  I'd download Filezilla and just try to ftp to the site you are attempting and make sure you can get the same file.  If that doesn't work you know it isn't to do with your script.  If it does I'd look for an alternative.
0
 

Author Comment

by:Sivasan
ID: 40603972
Thanks SStory, I will try few ftp solutions. Thanks for all your help
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cloud file services can fill many different roles for your business. Often, the use of cloud file services begins with employees using consumer products, like Dropbox, to share files with customers and each other. While sync-and-share can be an effe…
By default the complete memory dump option is disabled in windows . If we want to enable the complete memory dump for a diagnostic purpose, we have a solution for it. here we are using the registry method to enable this.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now