Pete Freitag Pete Freitag

FTP Scripts on windows

Published on January 31, 2003
By Pete Freitag
misc

I found this Microsoft KB article today #96269 which shows you how to use the ftp program that comes with all versions of windows an automate a file transfer.

ftp -s:script.txt ftp.server.com
The contents of script.txt might look like this:
yourUserName
yourPassword
bin
cd /files
put file.zip
bye

This is handy for administration between servers, but keep in mind that FTP sends passwords in clear text. You should use FTP over SSL or SFTP instead.




windows ftp utils tips

FTP Scripts on windows was first published on January 31, 2003.

If you like reading about windows, ftp, utils, or tips then you might also like:

Discuss / Follow me on Twitter ↯

Comments

What if you want to run an "automated" script but still have the user enter a username and password.. in other words do no have the username and password coded in the script?
Thanks
by Richard on 11/25/2004 at 8:40:18 AM UTC
I am running a .bat file that calls an ftp server and references the commands using a .txt file. Everything is working well.

My problem is when the built in windows FTP client tries to download a file from the ftp server using the get command, if the file does not exist on the server, it wipes out the file that is locally on my C: drive and leaves me with a blank file.

I must always keep the field headers in this file and as such I must make sure that if there is no file on the server to leave the one locally alone.

How can this be done?

(Is there a way to first look to see if the file exist and only then initiate the download?)

Need help - - - - - - Thanks!
by Steve Barak on 10/27/2006 at 7:47:02 AM UTC
When I ftp a file to my host system using a put, it defaults to record size to 80 bytes. I need this file to be 676 bytes on my host system. Can I do this using ftp?
by kris on 02/08/2007 at 7:48:14 AM UTC
i need to write a script download files through FTP. the script should ask password after putting password the should continue the script
by abdul on 10/27/2007 at 8:53:29 AM UTC
ftp -s:script.txt ftp.server.com
The contents of script.txt might look like this: yourUserName
yourPassword
bin
cd /files
put file.zip
bye
i tried thus comment nd its working,but if one pc got error,the script stops there,so can u recommend an script for exceptional handling..
by neethu on 10/07/2008 at 11:39:21 PM UTC
i need ftp command that move the file to ftp , i used the command mput and all work (its copy the files to target) but not delete the source files.
i need the command that copy and delete if the file transfer ok
by yuval barel on 01/07/2009 at 5:25:07 AM UTC
To get this to work for me, my script had to look like this:

open ftp.server.com
user name passwd
bin
get filename filename
bye

and my ftp invocation needed the -n

ftp -n -s:script.txt
by jeb6kids on 06/09/2009 at 11:19:10 AM UTC
Hi, I am trying to write a batch file that calls another text file with commands. My command prompt screen just keeps on scrolling when i click on the batch file. Here is what i have in batch file:
ftp -s:ftpbat.txt
prompt

And here is what i have in ftpbat.txt
open uhc51ip
user name
password

Can anyone tell me what is the mistake i am doing here.
Thanks in advance.
by sarav on 08/27/2009 at 12:24:00 PM UTC
I'm logged onto windows machine and have to get files from a unix server. So i created my script.txt as follows:

userid
password
bin
cd /mydir
get file1
bye

..and execute the script with:
ftp -s:ftpscript.txt server1

this works fine for 1 file, but i want to get over 10,000 files all with very different names; mget prompts for Y/N response; i can't get the folder name because there are over 60,000 files in the directory and i only want 10,000;
is there a command to read the entire list of files i want to ftp from a file and ftp?
by Dre on 03/10/2010 at 3:40:04 PM UTC
Is anyone could help, how files from one ftp site could be automatically movet to next secure ftp site in regular interval of time?
by Hemanta on 08/03/2010 at 8:29:24 AM UTC
I need to upload a file from my Windows box to a remote UNIX box.The file that needs to be transferred is very big (approx 200MB) in size and the network connectivity is very poor.The issue here is as soon as I try uploading that file and hardy 30-40% of the upload is completed,the network goes down and when I start it starts uploading from the beginning again.I need a process where I can upload the file and even if the network goes,suppose the network goes down when the file has uploaded 30%,when the network comes back, it sould start from 30% instead of starting from 0%.I mean that the upload should continue from the place it stopped. Could someone please help??
by Mandakini Mishra on 11/08/2010 at 4:57:13 AM UTC
I have to write a batch script which download file from ftp server(unix environment) which contain several same name

file with different modified date. Batch file should take two parameters file name and last modified date.that

script go to server and match file name according to its lastmodified date and download it to windows environment .

Please help
by Amit Srivastava on 01/06/2011 at 2:34:14 AM UTC
I have to write a batch script which download file from ftp server(unix environment) which contain several same name

file with different modified date. Batch file should take two parameters file name and last modified date.that

script go to server and match file name according to its lastmodified date and download it to windows environment .

Please help
by Amit Srivastava on 01/06/2011 at 2:35:10 AM UTC