Solved

Batch file to upload files to FTP server

Posted on 2004-08-22
6
1,679 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:Stimphy
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
withoutTen challenge 14 87
EvenOdd challenge 10 81
userCompare  challenge 3 61
changePi Challenge 15 75
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

11 Experts available now in Live!

Get 1:1 Help Now