Reputation: 767
I would like to upload a file to my ftp server if internet is connected
In each run, i prefer:
if (ftp server can be connected){
upload the file "C:\abc.txt" to the ftp server directory "/ABC_DB"
}
Thus, I am not sure how to check ftp connection, is it possible to run like this:
echo abc > C:\abc.txt
???Check the connection here
OPEN your.ftp.server.com
usernameabc
passwordbcd
CD /ABC_DB
PUT "C:\abc.txt"
QUIT
PAUSE
Sorry for asking such silly question, but I am new in batch, hope u can help me =[
Upvotes: 1
Views: 1357
Reputation: 41287
Test this: change lines 2,3,4 with your details
@echo off
set "name=your_ftp_user-name"
set "password=your_ftp_password"
set "server=ftp_server_name"
ping %server% |find /i "TTL=" >nul || (echo server offline, aborting&pause&goto :EOF)
set "ftpScript=%temp%\%~nx0.ftp.tmp"
(
echo open %server%
echo %name%
echo %password%
echo bin
echo CD /ABC_DB
echo PUT "C:\abc.txt"
echo quit
) > "%ftpScript%"
ftp -i -s:"%ftpScript%"
del "%ftpScript%"
Upvotes: 1