FTP Scripts on windows

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.


Related Entries

35 people found this page useful, what do you think?

Trackbacks

Trackback Address: 77/A4A6B36193F6E65C84F005F2A16B6C0B

Comments

On 12/12/2003 at 4:10:36 PM EST Shekhar wrote:
1
This uses standard/default port 21. Does anyone know how to specify a port in windows ftp ?? <ftp server port> and <ftp server:port> don't work.

On 01/14/2004 at 7:45:32 PM EST Anonymous wrote:
2
type ftp on the command promt ftp>open servername[space]port#

On 01/28/2004 at 7:31:45 AM EST Carben wrote:
3
uhm.. so the build-in windows ftp client cant upload folders?

On 05/19/2004 at 4:56:32 AM EDT ShoX wrote:
4
Windows ftp client can do folders. Just do mput <foldername>

On 10/14/2004 at 4:08:19 PM EDT alan O' neill wrote:
5
How does one include comments in the command file eg ftp -s:command_file 147.149.200.268

On 11/25/2004 at 10:40:18 AM EST Richard wrote:
6
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

On 12/28/2004 at 4:27:33 AM EST Prashanth wrote:
7
My req is like this User will specify the file name which shud be ftp'd to the server. Like

------------------------------ c:\>run.bat <FILE_NAME>

run.bat will have

ftp -n -s conn.bat

conn.bat will have

open 128.120.2.1 user guest guest lcd c:\ cd $DATA mput <FILE_NAME> bye

--------------------------------------- Hw do i go abt this?

Thanks in adv

Pls reply to a.prashanth@gmail.com

Prashanth

On 09/16/2005 at 7:35:13 AM EDT Harsha wrote:
8
this script not work instead of looping the command(ftp -n -s:foo.txt 11.11.11.11) how can i stop this Please help me

Harsha

On 09/23/2005 at 1:07:21 AM EDT PoonTang wrote:
9
Operators are standing by with Ettercap, to capture your FTP login and password. Thank you.

Use WinSCP instead kiddies.

On 07/19/2006 at 3:45:33 AM EDT Santhosh Jose wrote:
10
This was really useful.

Thanks,

On 09/07/2006 at 10:35:42 AM EDT Mr Holland wrote:
11
How can I use port# in combination with this command line?? "ftp -s:test.scr 11.11.11.11 21222" does not work. Error: "Transfers files to and from a computer running an FTP server service (sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A]" Yadiyadiya, it's the default command line help that pops up.

I'm so close to get my script working but can't find the solution for this last step.

Can you help me?

On 09/08/2006 at 8:48:57 AM EDT Mr Holland wrote:
12
Now I understand. Just like the first example where you talk about script.txt The trick is to add this line to script.txt: servername<space>port#

Which result in this script.txt: yourServerName yourPort# yourUserName yourPassword bin cd /files put file.zip bye

The ftp session can be started like this: ftp -s:script.txt

On 10/27/2006 at 9:47:02 AM EDT Steve Barak wrote:
13
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!

On 11/29/2006 at 9:22:22 PM EST maeven wrote:
14
Hi.. I'm also facing the same problem as Harsha whereby it'll only keep looping. How do i troubleshoot this? Your help would be much appreciated.

Thank you!

maeven

On 01/15/2007 at 3:36:48 PM EST Daria wrote:
15
ftp makes it loop, it looks for itself, if you name the file ftp.bat or ftp.exe You have to give it a direct link to look for the file, so instead of ftp -s:script.txt ftp.server.com

do c:\windows\system32\ftp -s:script.txt ftp.server.com

On 02/08/2007 at 9:48:14 AM EST kris wrote:
16
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?

On 04/04/2007 at 4:31:50 PM EDT mcky wrote:
17
i wnt to write ftp script that should ftp the files from windows to unix system. please guide ( shell / dos is only languages i hv to use0

On 04/04/2007 at 4:31:56 PM EDT mcky wrote:
18
i wnt to write ftp script that should ftp the files from windows to unix system. please guide ( shell / dos is only languages i hv to use0

On 04/05/2007 at 7:26:17 AM EDT iswaniey wrote:
19
Hi guys, I have multiple files in ftp directory. Anybody knows how to get the latest file from ftp?

Thanks.

On 08/15/2007 at 9:57:02 PM EDT mark wrote:
20
Hi all, I normally work with *NIX but had to do something from Windows to a nix host. The following is a simple script that does most of what has been asked for. Some of the gotos aren't working correctly but it functions to its design

ECHO OFF REM batch file to ftp a nominated file to a fixed host and directory REM This is so much easier to do in Unix...

REM Validate the input IF %1=="" GOTO error

REM write the script file for use by ftp SET scriptFileName=ftpScript.txt

ECHO open host >> %scriptFileName% ECHO user >> %scriptFileName% ECHO userName >> %scriptFileName% ECHO password >> %scriptFileName% ECHO ascii >> %scriptFileName% ECHO cd deployDirectory >> %scriptFileName% ECHO put %1 >> %scriptFileName% ECHO bye >> %scriptFileName%

REM now use the file. ftp -n -s:%scriptFileName%

REM now clean up the file del %scriptFileName%

ECHO FTP completed GOTO end

:error ECHO ftpFile. Sends a given a file to a nominated host ECHO usage ftpfile <fileToFTP> GOTO end

:end

On 10/27/2007 at 10:53:29 AM EDT abdul wrote:
21
i need to write a script download files through FTP. the script should ask password after putting password the should continue the script

On 12/05/2007 at 9:46:32 AM EST Flo wrote:
22
How can I force to delete some files via skript ?

the skript should login, change dir, delete files in there and upload the new ones.

i don't want to use mput * y y in the .txt as the files to be deleted may vary

any hints ?

On 01/08/2008 at 7:27:18 PM EST MimicBox wrote:
23
Flo > Your FTP program may support the command "PROMPT". I think that will switch off the confirmation questions (default behavior) that you get when you do M* commands (e.g. mput). So, put "Prompt" at the beginning of your FTP script. Hope that helps.

On 01/10/2008 at 5:58:58 PM EST MikeN wrote:
24
I need to FTP files that part of the file name is different i.e. file(date)(time).txt. I have tried to use the mput file_*.txt command but when it finds the file it prompts for confirmation of file (Y/N) How can I make it to assume Y and proceed automatically?

On 01/31/2008 at 5:10:39 AM EST kingkhan wrote:
25
i am able to automate username password and able to connect to server but mput or mget is not working plz help

On 02/28/2008 at 7:51:37 AM EST dms007 wrote:
26
use the command prompt before you use mget or mput is will disable the prompting feature

On 02/28/2008 at 7:53:01 AM EST dms007 wrote:
27
i mean the command "PROMPT"

On 03/17/2008 at 7:54:05 AM EDT Stanley wrote:
28
The contents of script.txt might look like this:

yourUserName yourPassword bin cd /files put file.zip bye

How can i hidden the password and userid in script.txt file ?

thank you so much.

On 10/03/2008 at 2:32:07 AM EDT Harry wrote:
29
After messing about with ftp.exe for a few hours, I searched the web and found a program called Sysax FTP Automation to automate ftp exactly the way I wanted it to. Their website is at http://www.sysax.com and the personal edition of the program is free.

On 10/08/2008 at 1:39:21 AM EDT neethu wrote:
30
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..

On 11/05/2008 at 3:21:09 AM EST minh wrote:
31
Hi, what does the script file look like if my password is empty

On 12/18/2008 at 6:54:20 AM EST Mesfin Melesse wrote:
32
Hi, I want to use an ftp script and I want to enter the user Id and Password interactively. Help me. Regards, Mesfin

On 01/07/2009 at 7:25:07 AM EST yuval barel wrote:
33
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

On 01/20/2009 at 2:04:02 PM EST Angel Merrett wrote:
34
Thanks! You just saved me tonnes of time. God I love the internet.

On 05/05/2009 at 5:41:26 AM EDT Deepak wrote:
35
This doesnt work with windows vista ------------------------

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.

On 06/09/2009 at 1:19:10 PM EDT jeb6kids wrote:
36
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

On 06/09/2009 at 1:22:12 PM EDT jeb6kids wrote:
37
Once more with more newlines :)

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

On 06/30/2009 at 6:07:09 AM EDT Rosen wrote:
38
Hi, I want to write script to open ftp with user and password in one script echo off ftp ftp.server.com username password

doesnt work help me please how with one comand to get in ftp

On 07/02/2009 at 1:45:23 PM EDT Anonymous wrote:
39
I need to append the date/time to a file I'm FTP'ing to another server. my current script is:

ftp -i -s:d:\Apps\Myfile\Scripts\Send_Approvals.ftp "IP Address">> c:\Apps\Myfile\Archive\ApprovalsSendFTPLog.txt

move "c:\Apps\Myfile\Files\Approvals.csv" "c:\Apps\Myfile\Archive"

My question is do I need to write a seperate script to append the date/time to the file? Or can I include it in the above?

Thanks Sam

On 08/27/2009 at 6:02:32 AM EDT sarvan wrote:
40
Hi, I want to upload a file automated to ftp server using batch file in windows script

On 08/27/2009 at 2:24:00 PM EDT sarav wrote:
41
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.

On 01/06/2010 at 2:37:02 PM EST PatrickMc wrote:
42
Here is an automated way to ftp upload files to an ftp web site.

#Script FTPUpload.txt var str site, login, pswd, localdir set $site = "ftp.mysite.com" set $login = "me" set $password = "my_password" set $localdir = "/path/to/local/files"

echo $login "\n" $password > "commandfile.txt"

cd $localdir var str list, file lf -n "*.html" "/myhtmlfiles" ($fmtime >= "20100101") > $list while ($list <> "") do lex "1" $list > $file echo "put " $file >> "commandfile.txt" done

echo "bye" >> "commandfile.txt" system ftp "-s:commandfile.txt " $site

This script will upload all .html files modified since Jan 1, 2010. You can modify the script to customize it further.

To try as is, first save the script to file C:/Scripts/FTPUpload.txt, change the values of variables $site, $login, $password and $localdir to the correct values.

Script is in biter scripting language. Start biterscripting and enter the following command.

script "C:/Scripts/FTPUpload.txt"

If you don't have biterscripting, you can download it from http://www.biterscripting.com or any other local download site.

On 01/06/2010 at 2:38:32 PM EST PatrickMc wrote:
43
Here is an automated way to ftp upload files to an ftp web site.

#Script FTPUpload.txt var str site, login, pswd, localdir set $site = "ftp.mysite.com" set $login = "me" set $password = "my_password" set $localdir = "/path/to/local/files"

echo $login "\n" $password > "commandfile.txt"

cd $localdir var str list, file lf -n "*.html" "/myhtmlfiles" ($fmtime >= "20100101") > $list while ($list <> "") do lex "1" $list > $file echo "put " $file >> "commandfile.txt" done

echo "bye" >> "commandfile.txt" system ftp "-s:commandfile.txt " $site

This script will upload all .html files modified since Jan 1, 2010. You can modify the script to customize it further.

To try as is, first save the script to file C:/Scripts/FTPUpload.txt, change the values of variables $site, $login, $password and $localdir to the correct values.

Script is in biter scripting language. Start biterscripting and enter the following command.

script "C:/Scripts/FTPUpload.txt"

On 02/12/2010 at 7:43:48 AM EST peppi wrote:
44
i have the ftp command that put the file from the local pc to a host pc by 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 the file at the local pc if the file transfer ok

On 03/10/2010 at 5:40:04 PM EST Dre wrote:
45
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?

On 04/20/2010 at 5:18:07 PM EDT Anonymous wrote:
46
Is there a way to automatically move files from a ftp site to a windows folder?

On 06/14/2010 at 10:30:35 AM EDT Pranav Pachchigar wrote:
47
--------------------- #sCRIPT STARTS HERE

HOST='ipaddres' USER='username' PASSWORD='passwd'

pwd

echo "Enter data (Rxxxxxx.ZED) File name : " read cmd2 ftp -n $HOST <<END_SCRIPT quote USER $USER quote PASS $PASSWORD

bin hash

cd /usr/sap/trans/data lcd /usr/sap/trans/data mget R$cmd2* #SCRIPT END ------------------------

Can any one tell i want to loop this script to mget more then one file,

I can get on file but i want to prompt next file name to get. And after given input for all files it starts mget.

On 07/01/2010 at 10:41:15 AM EDT raviraj singh wrote:
48
i hv a file in my pc. i want to copy that file into another pc in my network autometically. for this i need to create a ftp and than a batch file of that ftp. and schedule that batch file to daily. so it will copy my file to another pc daily autometicaally. can it happens at window. if yes than help me to do it. call me if you can at 09776018305 i ll be thankfull to you. its urgent.

On 08/03/2010 at 10:29:24 AM EDT Hemanta wrote:
49
Is anyone could help, how files from one ftp site could be automatically movet to next secure ftp site in regular interval of time?

On 09/04/2010 at 2:06:36 PM EDT Jai Adwani wrote:
50
I need to write a script to fetch file from unix to windows machine, I have successfully written that, above discussion helped me in this, Thanks for that :)

Now i want to add commands in script for verifying size. after fetching file, if size of file at at remote and local machine is same, then script should continue, else it should prompt for error.

Currently I have written script in two files as : File : "script" Content : user abc abc bin cd /amd_stage2/OMS/R14/build_240/ get ThirdPartyApplications_R14.zip bye

and file : "fetch.bat"

Content : ftp -n -s:script phd026a.pedc.sbc.com

On 11/03/2010 at 6:37:07 AM EDT Satinder wrote:
51
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 -n -s:test.src 192.168.301.154 And here is what i have in test.src open username password put Tours.pdf quit

Can anyone tell me what is the mistake i am doing here. Thanks in advance.

Pl. reply on my mail id satinder_dhar@yahoo.com

Regards Satinder

On 11/03/2010 at 6:40:10 AM EDT Satinder wrote:
52
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 -n -s:test.src 192.168.301.154 And here is what i have in test.src open username password put Tours.pdf quit

Can anyone tell me what is the mistake i am doing here. Thanks in advance.

Pl. reply on my mail id satinder_dhar@yahoo.com

Regards Satinder

On 11/08/2010 at 6:57:13 AM EST Mandakini Mishra wrote:
53
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??

On 01/06/2011 at 4:34:14 AM EST Amit Srivastava wrote:
54
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

On 01/06/2011 at 4:35:10 AM EST Amit Srivastava wrote:
55
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

On 01/11/2012 at 3:53:41 PM EST Jesse R wrote:
56
This is what made my script work (THANKS DARIA!!!)

c:\windows\system32\ftp -s:script.txt ftp.server.com

just calling FTP didn't work for me in win 7 64 ultimate.

On 03/15/2012 at 6:57:34 PM EDT Hainnyden wrote:
57
Good <http>//freecreditscoretoday.net Credit Score online] Nowadays is done via willpower with your shelling out practices. In case you follow these tips you're sure to improve your credit as well as finally build your lifestyle easier <http>//freecreditscoretoday.net Free Credit Score]

On 04/25/2012 at 5:01:19 PM EDT swahil wrote:
58
Thanks a lot! this was quick n easy

On 06/07/2012 at 12:16:34 PM EDT Optics wrote:
59
Hey guys, I couldn't agree more. I really donhttp://bestelectricshaverhq.org - 't get why more people just don't get it. Great post, keep it up. Cheers!

On 04/12/2013 at 7:39:35 PM EDT Fjodr Soyevskji wrote:
60
An easier way to script FTP file transfers may be FtpScripter, check it out at www.ftpscripter.com

Post a Comment




  



Spell Checker by Foundeo

Recent Entries



foundeo


did you hack my cf?