Solved

Batch file to download a file from FTP server

Posted on 2015-02-03
6
428 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

As a financial services provider, your business is impacted by two of the strictest federal regulations on record: the Sarbanes-Oxley Act and the Gramm-Leach-Bliley Act. Correctly implementing faxing into your organization to provide secure, real-ti…
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
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…

751 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