Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I saw a script for batching commands to an ftp server on http://www.batch.hpg.ig.com.br/
(excellent site)
I'm attempting to do this very same thing, and the script seems to work great, but what happens when the ftp server doesn't accept the connection, for one reason or another? I have a need to upload files daily, but the ftp server i connect to is very finicky, and sometimes it just won't let me on until the 2nd or 3rd try, so can I make the script in such a way that it tries, and if it can't connect, then try again in a few seconds, or at least write out an error message letting me know that i'll have to try to upload the file again? Thanks so much for any help you could offer me.Mike
effervescent@hotmail.com

> I saw a script for batching commands
> to an ftp server on
> http://www.batch.hpg.ig.com.br/
> (excellent site)Thanks =D (I'm the author hehe)
Identify a certain string or character which is only outputted if the connect if successful. If you're using the 100% automatic method, there are lots of strings, such as "Connected" (that would be language-dependent) and "220" (that's the code which appears after server initial messages. If you're on the other method, which needs password input, the string ":" would be a good choice.
Now, look for that string on the output from the command. Example:
===== BATCH SCRIPT BEGIN =====
@echo off:: here goes the making of the FTP script
set try=
:loop
set try=.
FTP -n -s:FTP.DAT |FIND "220" > nul
if not errorlevel=1 goto ok
if "%try%"=="..." goto error
goto loop:error
echo Error - tryed 3 times, no good !
goto end:ok
echo Process sucessful!
goto end:end
set try=
===== BATCH SCRIPT END =====Got it?
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Leonardo,
Eh? You'll have to excuse me, I'm a bit of a novice at this.
So, what I have now is:
@echo off
echo OPEN ftp.here.com>> %TEMP%.\CEN.DAT
echo USER mylogin>> %TEMP%.\CEN.DAT
echo mypassword>> %TEMP%.\CEN.DAT
echo cd mydir>> %TEMP%.\CEN.DAT
echo cd myotherdir>> %TEMP%.\CEN.DAT
echo bin>> %TEMP%.\CEN.DAT
echo hash>> %TEMP%.\CEN.DAT
echo put %1>> %TEMP%.\CEN.DAT
echo quit>> %TEMP%.\CEN.DAT
FTP -n -s:%TEMP%.\CEN.DATWhere do I put this in the 2nd script you gave me? Do I put all of this just after the
SET TRY=.
or do I have to restructure the whole thing.
Thanks again for you're help. You're a lifesaver!
Mike

Hi, Mike. You should put only the ECHO part (which is the creation of the FTP script) on the place I pointed. This is it:
===== BATCH SCRIPT BEGIN =====
@echo offecho OPEN ftp.here.com> %TEMP%.\CEN.DAT
echo USER mylogin>> %TEMP%.\CEN.DAT
echo mypassword>> %TEMP%.\CEN.DAT
echo cd mydir>> %TEMP%.\CEN.DAT
echo cd myotherdir>> %TEMP%.\CEN.DAT
echo bin>> %TEMP%.\CEN.DAT
echo hash>> %TEMP%.\CEN.DAT
echo put %1>> %TEMP%.\CEN.DAT
echo quit>> %TEMP%.\CEN.DATset try=
:loop
set try=.
FTP -n -s:%TEMP%.\CEN.DAT |FIND "220" > nul
if not errorlevel=1 goto ok
if "%try%"=="..." goto error
goto loop:error
echo Error - tryed 3 times, no good !
goto end:ok
echo Process sucessful!
goto end:end
set try=
===== BATCH SCRIPT END =====That's it! Watch out - the first ECHO line (open server) should have only one greater-than sign. That's to be sure it will the first line on the file (in case there's already some data on it, for one reason or another).
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Thanks Leonardo, it's so great have a place to pick the brains of knowledgeable people like yourself. I really appreciate your help and understanding.
Mike

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |