0

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

1
  • /* Missing tag: windows */
    – Vi.
    Commented Jul 6, 2010 at 15:52

4 Answers 4

1

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
4

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.

1
  • Honestly i just interested in native windows scripting more.
    – Freshblood
    Commented Jul 6, 2010 at 17:38
0

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

1
  • 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
    Commented Jul 6, 2010 at 18:17
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .