Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Running FTP from a batch file

440 views
Skip to first unread message

NeillH

unread,
Jun 18, 2009, 9:40:37 AM6/18/09
to
Hi ALL

I am having problem running ftp commands from a batch file.

Ruuning through command works OK but when I run from my batch file the
cmd windows just loops through. I am sure this is a simple fix
because it works manually. You may have guessed I do not know too
much about batch files.

Batch File
@echo
ftp -i -n -s:ftp.txt
CSL
EXIT

Text File for FTP
open my_ipaddress
myuser
mypassword
cd mydir

mget *.txt c:\*.*

quit

Any ideas :-(

Robert Roland

unread,
Jun 18, 2009, 9:48:09 AM6/18/09
to
On Thu, 18 Jun 2009 06:40:37 -0700 (PDT), NeillH
<ne...@nannygroup.net> wrote:

>when I run from my batch file the
>cmd windows just loops through.

You didn't name your batch file "ftp.bat", did you?
--
RoRo

Andrew

unread,
Jun 18, 2009, 2:50:28 PM6/18/09
to
NeillH schrieb:

Hi,

It seems there are several ways. I�m not so sure what -n does. Here�s
How i do it

My Batchfile looks like this (it�s called getit.bat)


ftp -i -s:ftp.dat


Here now what�s inside that ftp.dat (variables start with _ and have to
be changed to your commands)


open _ip
_username
_password
_command-1
_command-2
bin
bye
exit

before i begin a binary transfer i switch to binary mode with the
command bin ... don�t know if mget implies bin

regarding mget *.txt c:\*.*

regarding your CSL command i guess you meant to write CLS ... right ?


I would suggest to be carefull with that command ... at least
give it a good testperiod :) i know what i�m talking about

If your batchfile is called ftp.bat you need to change

ftp -i -s:ftp.dat to %SystemRoot%\system32\ftp.exe -i -s:ftp.dat

assuming you are using XP ... so it won�t loop

Andrew

NeillH

unread,
Jun 18, 2009, 5:21:34 PM6/18/09
to
> Andrew- Hide quoted text -
>
> - Show quoted text -

Thanks everyone, renaming the ftp.bat and worked great, just so I can
understand the problem what was the issue with calling file ftp.bat

Neill

Andrew

unread,
Jun 18, 2009, 5:40:27 PM6/18/09
to
NeillH schrieb:

> Thanks everyone, renaming the ftp.bat and worked great, just so I can
> understand the problem what was the issue with calling file ftp.bat
>
> Neill

by calling it ftp.bat it worked as a loop. Since you want to run a file
name ftp(exe) the OS first looks (what you got in your batchfile) inside
the folder it resides. Then it follows the PATH

Maybe you wanna check out wikipedia for more info :) i�m too lazy to
write it all down right now :)


Andrew

Todd Vargo

unread,
Jun 18, 2009, 11:17:03 PM6/18/09
to

Simply adding .exe to the ftp command will prevent the loop.

ftp.exe -i -n -s:ftp.txt

However, it is a good practice to avoid using the same name as utilities. In
this case, a better name for the batch would have been
Download_txt_files.bat

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

Andrew

unread,
Jun 19, 2009, 3:27:19 AM6/19/09
to
Todd Vargo schrieb:

> Andrew wrote:
>> NeillH schrieb:
>>
>>> Thanks everyone, renaming the ftp.bat and worked great, just so I can
>>> understand the problem what was the issue with calling file ftp.bat
>>>

> Simply adding .exe to the ftp command will prevent the loop.

only if it can be found true the path statement :)

using %SystemRoot%\system32\ftp.exe would be my choice


Andrew

Todd Vargo

unread,
Jun 19, 2009, 5:40:37 PM6/19/09
to
Andrew wrote:
> Todd Vargo schrieb:
> > Andrew wrote:
> >> NeillH schrieb:
> >>
> >>> Thanks everyone, renaming the ftp.bat and worked great, just so I can
> >>> understand the problem what was the issue with calling file ftp.bat
> >>>
>
>
> > Simply adding .exe to the ftp command will prevent the loop.
>
> only if it can be found true the path statement :)

That is a different issue from the batch restarting in a loop. The point
was, when ftp.exe is specified, ftp.bat in current folder will not be run by
mistake.

>
> using %SystemRoot%\system32\ftp.exe would be my choice

No comment on personal preferences.

0 new messages