Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i am trying to write a bat file on windows xp. I can connect ftp server and download files by console but i can't make it work by unattended bat file.

ftp 127.0.0.1 //connect server but ask username and password manualy how can i connect autamticly with password ?

i have tried ftp 127.0.0.1 pass pass but doesn't work. all commands here

share|improve this question
    
/* Missing tag: windows */ –  Vi. Jul 6 '10 at 15:52
    
Thanks that's fixed –  Freshblood Jul 6 '10 at 18:19

4 Answers 4

up vote 1 down vote accepted

Save this as a batch file and run it

echo user  >> ftpcommands.txt
echo myusername>> ftpcommands.txt
echo mypassword>> ftpcommands.txt
echo get file1>> ftpcommands.txt
echo get file2>> ftpcommands.txt
echo quit  >> ftpcommands.txt
ftp -n -s:ftpcommands.txt ftp.example.com
del ftpcommands.txt
share|improve this answer

I tend to avoid batching with vanilla windows FTP. I recommend trying out WinSCP: It's free, it's got robust scripting capabilities, and it's got a lot more features than the default FTP client that comes with Windows.

share|improve this answer
    
Honestly i just interested in native windows scripting more. –  Freshblood Jul 6 '10 at 17:38

Try the -s:script.txt method of scripting, as described here. Basically, you create a script file like this:

user
myusername
mypassword
get file1
quit

And invoke it like so:

ftp -n -s:script.txt ftp.example.com

share|improve this answer
    
but problem is we are using 2 files so i have to always send 2 file there and this is what i don't want. I can do all my job by command line but i cant make unattended batch file yet :{ –  Freshblood Jul 6 '10 at 18:17

Best solution is write commands into text file then send that text file as parameter.

echo user nod32 nod32 >ftp.txt

echo get my.text d:\my.txt >> ftp.txt

echo cd Books >>ftp.txt

ftp -n -s:ftp.txt localhost
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.