pf » FTP Scripts on windows

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
14 people found this page useful, what do you think?

Trackback Address: 77/A4A6B36193F6E65C84F005F2A16B6C0B
On 12/12/2003 at 2:10:36 PM MST 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 5:45:32 PM MST Anonymous wrote:
2
type ftp on the command promt ftp>open servername[space]port#

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

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

On 10/14/2004 at 2:08:19 PM MDT 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 8:40:18 AM MST 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 2:27:33 AM MST 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 5:35:13 AM MDT 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/22/2005 at 11:07:21 PM MDT 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 1:45:33 AM MDT Santhosh Jose wrote:
10
This was really useful.

Thanks,

On 09/07/2006 at 8:35:42 AM MDT 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 6:48:57 AM MDT 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 7:47:02 AM MDT 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 7:22:22 PM MST 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 1:36:48 PM MST 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 7:48:14 AM MST 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 2:31:50 PM MDT 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 2:31:56 PM MDT 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 5:26:17 AM MDT 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 7:57:02 PM MDT 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 8:53:29 AM MDT 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 7:46:32 AM MST 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 5:27:18 PM MST 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 3:58:58 PM MST 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 3:10:39 AM MST 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 5:51:37 AM MST dms007 wrote:
26
use the command prompt before you use mget or mput is will disable the prompting feature

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

On 03/17/2008 at 5:54:05 AM MST 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.




  



Spell Checker by Foundeo





Subscribe to my RSS Feed: solosub RSS
Tags