11

I have setup a separate FTP account for this.

Here is the info:

FTP Username: ahk@proflightsimulatoreview.com
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.

Martin Prikryl
  • 147,050
  • 42
  • 335
  • 704
kmoney12
  • 3,657
  • 4
  • 29
  • 51
  • 5
    http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/ – Alex K. Oct 29 '11 at 09:21
  • Thanks for the link, but I have honestly tried all that. I realize I am asking to be completely spoonfed, but I have seriously been trying for hours. I gave the FTP account info so that someone could help me fill all the blanks in, since I am obviously doing it wrong. Also, I do not want to upload from a command prompt, I just want to run the batch file and have it done for me – kmoney12 Oct 29 '11 at 09:23
  • what happens when you run the script from that site? – Alex K. Oct 29 '11 at 09:23
  • didnt work the first time, but I'll try again. thanks again – kmoney12 Oct 29 '11 at 09:27
  • Have you tried the [ncFTP Client](http://www.ncftp.com/ncftp/) from the command line?? Works like a charm for all my needs of transmitting files to FTP from a command prompt – marc_s Oct 29 '11 at 10:17

4 Answers4

16

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

1. Saving this as MYFTP.bat:

@echo off
echo user ahk@proflightsimulatoreview.com> 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 ahk@proflightsimulatoreview.com
331 User ahk@proflightsimulatoreview.com 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.
Alex K.
  • 159,548
  • 29
  • 245
  • 267
  • Thanks so much for the answer...it doesnt seem to be working correctly though. I opened up a command prompt, typed cd C:\Users\Kyle\Desktop\ftptest\ to get into the right directory, and then typed FTP.bat C:\Users\Kyle\Desktop\ftptest\thetest.txt Now it seems stuck...nothing else is happening :( – kmoney12 Oct 29 '11 at 09:45
  • it is making the ftpcmd.dat file so I know that it is somewhat working. so frustrating:( – kmoney12 Oct 29 '11 at 09:53
  • try temp disabling the windows firewall – Alex K. Oct 29 '11 at 09:59
  • its off...never had it on. I can use filezilla and clients to connect perfectly. what does your ftpcmd.dat read while it is uploading? – kmoney12 Oct 29 '11 at 10:01
  • Mine looks like this: user ahk@proflightsimulatoreview.com ahktest put -n quit – kmoney12 Oct 29 '11 at 10:02
  • sorry! when I tested it I used a junk qweqweqe.BAT file and used the tidier FTP.BAT name in the example - FTP.BAT/FTP.EXE - the names conflict; rename the .BAT file to MYFTP.BAT or similar and it should work – Alex K. Oct 29 '11 at 10:17
  • Now I get the error, 'ftp' is not recognized as an internal or external command. Perhaps this is my problem all along. Do I not have the necessary windows files for ftp? I am running windows 7. – kmoney12 Oct 29 '11 at 17:46
  • THANK THANK THANK YOU SO MUCH :D I had to put the .bat files in the system32 folder for it to work. Otherwise it couldnt find the FTP command? Thanks man, you are the best! – kmoney12 Oct 29 '11 at 17:52
  • Your welcome, if you make the 1st line in the bat file cd `c:\windows\system32` you should be able to put it anywhere – Alex K. Oct 30 '11 at 11:43
6

I did it like that:

1st bat:

startupload.bat
ftp -i -s:upload.bat

2nd bat: upload.bat :

open ftp.yourserver.com
username 
password 
cd public_html 
cd Ftp 
binary
put C:\Users\Desktop\something.txt
bye

you run it by opening startupload.bat (if that doesn't work, open cmd.exe and move startupload.bat in it and hit Enter. It will show you where is problem)

gengisdave
  • 1,704
  • 5
  • 18
  • 17
0

Create a batch file like this:

@echo off

echo USERNAME> upload.txt
echo PASSWORD>> upload.txt
echo asc>>upload.txt
echo put UPLOAD_FILE_NAME FTP_PATH_TO_STORE_FILE>> upload.txt
echo quit >> upload.txt


ftp -s:upload.txt SERVER_NAME.COM

del upload.txt

UPLOAD_FILE_NAME : - you can store file to be uploaded in the same directory where the batch file exists or give file name with absoulte path.I.e I need to upload a file called register.exe I should use

echo put register.exe, If register.exe is exists in the batch directory or echo put d:\myfiles\register.exe, If register.exe is exists in another folder(myfiles folder in d drive)

FTP_PATH_TO_STORE_FILE:- This is the FTP path where I need to put my file.For example /home/myftpfolder/register.exe

del upload.txt :- its optional because when executes batch file this upload.txt will stores in the directory with FTP username and password

If I've my server name is theserver.com then the batch file should be write like

@echo off
echo user123> upload.txt
echo 123TTyyy#>> upload.txt
echo asc>>upload.txt
echo put register.exe /home/myfiles/register.exe>> upload.txt
echo quit >> upload.txt
 ftp -s:upload.txt theserver.com
del upload.txt
Vivek S.
  • 15,777
  • 6
  • 54
  • 78
0

The easy way to upload to server is make a script file :
Code :

(
echo USERNAME
echo PASSWORD
echo asc
echo put C:\Users\Kyle\Desktop\ftptest\thetest.txt
echo quit
)>temp.txt
ftp SERVER_DOAMIN -s:temp.txt
del temp.txt /q >nul


So, the USERNAME is a username, and PASSWORD is a password, SERVER_DOMAIN is a server domain (not ftp:// at the top)