Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Batch file to download a file from FTP server

Posted on 2015-02-03
6
Medium Priority
?
472 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Files go missing when using DFS (Distributed File System) Replication and how to recover them and fix it.
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

719 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