FTP Scripts on windows

January 31, 2003
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?

Comments

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.
type ftp on the command promt ftp>open servername[space]port#
uhm.. so the build-in windows ftp client cant upload folders?
Windows ftp client can do folders. Just do mput <foldername>
How does one include comments in the command file eg ftp -s:command_file 147.149.200.268
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
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
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
Operators are standing by with Ettercap, to capture your FTP login and password. Thank you. Use WinSCP instead kiddies.
This was really useful. Thanks,
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?
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
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!
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
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
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?
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
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
Hi guys, I have multiple files in ftp directory. Anybody knows how to get the latest file from ftp? Thanks.
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
i need to write a script download files through FTP. the script should ask password after putting password the should continue the script
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 ?
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.
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?
i am able to automate username password and able to connect to server but mput or mget is not working plz help
use the command prompt before you use mget or mput is will disable the prompting feature
i mean the command "PROMPT"
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.
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.
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..
Hi, what does the script file look like if my password is empty
Hi, I want to use an ftp script and I want to enter the user Id and Password interactively. Help me. Regards, Mesfin
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
Thanks! You just saved me tonnes of time. God I love the internet.
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.
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
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
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
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
Hi, I want to upload a file automated to ftp server using batch file in windows script
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.
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.
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"
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
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?
Is there a way to automatically move files from a ftp site to a windows folder?
---------------------
#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.
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.
Is anyone could help, how files from one ftp site could be automatically movet to next secure ftp site in regular interval of time?
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
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
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
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??
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
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
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.
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]
Thanks a lot! this was quick n easy
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!
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?