Solved

Batch file to download a file from FTP server

Posted on 2015-02-03
6
387 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
no display on laptop 5 56
pdf to word 13 59
Why does Windows update fail? 8 41
Windows 7 Home Premium - not updating 3 30
Outsource Your Fax Infrastructure to the Cloud (And come out looking like an IT Hero!) Relative to the many demands on today’s IT teams, spending capital, time and resources to maintain physical fax servers and infrastructure is not a high priority.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.

744 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

15 Experts available now in Live!

Get 1:1 Help Now