Solved

Batch file to upload files to FTP server

Posted on 2004-08-22
6
1,685 Views
Last Modified: 2008-03-06
I need a batch file that would do this:
(I would normaly do this manually in CMD)

open ftp.***.com

User: ***.com
Password: ***

cd htdocs
lcd C:/mysite

mput * except database

quit
0
Comment
Question by:jonnyfb
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Stimphy
ID: 11865426
In your batch put something like

ftp -s:ftp.txt
exit

The -s Switch stands for Script
this will load the specified script file for your ftp session

In ftp.txt put your code

open ftp.***.com
***.com
***
cd htdocs
lcd C:/mysite
mput * except database
bye
0
 
LVL 1

Expert Comment

by:fattumsdad
ID: 11866285
Have you considered trying VBScript to do this?  If you'd like to give it a shot, try this:

Option Explicit
Dim objShell, objShell2
Set objShell = CreateObject("WScript.Shell")

objShell.Run "ftp" 'open FTP
Wscript.Sleep 500 'Pause
objShell.SendKeys "open ftp.**.com {ENTER}" 'Make sure you leave the {ENTER} in there...
objShell.SendKeys "USERNAME {ENTER}" 'FTP login name
objShell.SendKeys "PASSWORD {ENTER}" 'FTP password
objShell.SendKeys "cd htdocs" 'Change dir cmd
objShell.SendKeys "lcd c:\MySite"
objShell.SendKeys "mput * except database"
objShell.SendKeys "quit"
Wscript.Sleep 1000
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11873226
Thankyou Stimphy!

But when I put mput * except database I was wondering if you could explain how to  put all files except ones with the .mdb extention
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 3

Expert Comment

by:Stimphy
ID: 11875462
How many different types of files can exist in this DIR?  My guess is probably not many, so do something like this.

mput *.exe *.zip *.txt

A less efficient way is
mput *
mdelete *.mdb

Regaurds,
Dave
0
 
LVL 1

Author Comment

by:jonnyfb
ID: 11901122
I need some way of saying yes when it prompts me with a ? because at the moment it just says:

mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm? mput file.htm?

But it doesnt actually put the files! How will I overcome this problem?
0
 
LVL 3

Accepted Solution

by:
Stimphy earned 125 total points
ID: 11901482
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

786 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