Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch file to upload .txt to FTP

I have setup a separate FTP account for this.

Here is the info:

FTP Username: [email protected]
FTP Server: ftp.proflightsimulatoreview.com
FTP Server Port: 21
FTP Password: ahktest

Text file I want to upload: C:\Users\Kyle\Desktop\ftptest\thetest.txt

Please show me how to do this with batch. My understanding is that you make a separate txt file with the FTP commands and then you use a batch file to run it. Well I must have not plugged in the info right because it didn't work.

So here I am giving you the information. Please show me how to upload a text file.

like image 609
kmoney12 Avatar asked Oct 29 '11 09:10

kmoney12


1 Answers

I just put HELLO.TXT in your ftp root by;

1. Saving this as MYFTP.bat:

@echo off
echo user [email protected]> ftpcmd.dat
echo ahktest>> ftpcmd.dat
echo put %1>> ftpcmd.dat
echo quit>> ftpcmd.dat
ftp -n -s:ftpcmd.dat ftp.proflightsimulatoreview.com
del ftpcmd.dat

2. From the command line, in the same directory as MYFTP.BAT, running;

MYFTP.BAT c:\temp\hello.txt

result

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 05:17. Server port: 21.
220 You will be disconnected after 15 minutes of inactivity.
ftp> user [email protected]
331 User [email protected] OK. Password required

230-OK. Current restricted directory is /
230 0 Kbytes used (0%) - authorized: 51200 Kb
ftp> put hello.txt
200 PORT command successful
150 Connecting to port 59363
226-0 Kbytes used (0%) - authorized: 51200 Kb
226-File successfully transferred
226 0.563 seconds (measured here), 14.20 bytes per second
ftp: 8 bytes sent in 0.34Seconds 0.02Kbytes/sec.
ftp> quit
221-Goodbye. You uploaded 1 and downloaded 0 kbytes.
221 Logout.
like image 146
Alex K. Avatar answered Oct 05 '22 01:10

Alex K.