Computing.Net > Forums > Disk Operating System > 'smart' FTP batch help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

'smart' FTP batch help

Reply to Message Icon

Name: Mike
Date: September 17, 2002 at 12:20:26 Pacific
OS: winme
CPU/Ram: celeron 566, 192MB
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: September 17, 2002 at 14:19:45 Pacific
Reply:

> 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


0

Response Number 2
Name: Mike
Date: September 18, 2002 at 14:00:27 Pacific
Reply:

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.DAT

Where 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


0

Response Number 3
Name: Secret_Doom
Date: September 19, 2002 at 08:08:00 Pacific
Reply:

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 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

set 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


0

Response Number 4
Name: Mike
Date: September 19, 2002 at 14:26:09 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: 'smart' FTP batch help

FTP batch file www.computing.net/answers/dos/ftp-batch-file/4647.html

Dos Batch file for Dos FTP www.computing.net/answers/dos/dos-batch-file-for-dos-ftp/423.html

Auto ftp batch www.computing.net/answers/dos/auto-ftp-batch/14183.html