1.

Solve : FTP Batch Script?

Answer»

I have batch script for simple FTP (import/export) with out any error handling.

I would like write error checking so that i can catch the server time out, down. or any other reason batch file fail.

Any example of how to TAKE care of this task ?

Here is my sample code:

Code: [Select]C:
cd\some file destination
call format
del UpdateLog16.txt
ren UpdateLog15.txt UpdateLog16.txt
ren UpdateLog.txt UpdateLog1.txt
ftp -n -i -s:c:2ndbatch.txt > UpdateLog.txt

Here is the 2nd batch file:

open some FTP Site
user
password
cd /some dir...
bin
mput *.jpg
close


Thanks In Advance
are you SAYING like a way to trouble shoot what is going on??? If thats what you're refering too, i would suggest putting pauses in there to watch what each line does specifically.... and see where it goes wrong that way... The batch script that i runs twice a day. And sometimes it failes and i would just like to figure out why and when it failes.

Maybe out put the result to log file or something .

if it fails everytime??? the only suggestion i have is that when i'm building batch files for some stuff that i work on, i put pauses in a bunch of areas, and see if it tells me

"error blah blah has occured" then i can go off of that. Try to put pauses in there, other than that i have no idea how to input error messages into files or anything...Singleton06,

Thanks for the suggestion. But i'm very new to batch files. Can you give me example of how to put pauses in batch file.
Quote

Singleton06,

Thanks for the suggestion. But i'm very new to batch files. Can you give me example of how to put pauses in batch file.


normaly, just use the command "pause" and it says: press any key to continue Perhaps this might help.

@ECHO off

rem ################################################################################
rem # Created by: Gustaaf Von Pickartz
rem # Date: November 20th, 2005
rem #
rem ################################################################################

set FTPUSER=username
set FTPPWD=password
set FTPDIR=C:\TEMP\FTP
set ANYFILE=C:\DIR\FILE.ZIP

echo open ftp.server.com > send.ftp
echo user %FTPUSER% %FTPPWD% >> send.ftp
echo binary >> send.ftp
echo cd incoming >> send.ftp
echo put %FTPDIR%\%ANYFILE% >> send.ftp
echo bye >> send.ftp
ftp -i -n -s:send.ftp

del /f send.ftp
exit

what i was refering to as a pause is to literally put the word "pause" on a completely different line

such as

@echo off
echo Hello How are you doing?
pause
ehco I'm good...
pause
end

now, i spelled the word echo wrong on the second line and if you were to RUN through this as a batch file, it iwll tell you that "ehco is not an internal or external command" I will also have to hit a key to continue, so i will have time to watch what happens, and be able to tell that i have spelled the word wrong
This is just a quick suggestion, which you may be able to tell what you did wrong by the exmaple provided above....Okay, I'm confussed about the thread now.

did you want to know how to automate an FTP script or Errorcheck your batch files?

You can can do error checking in a batch.

Using Errorlevel as checking tool:

COPY C:\TEMP\*.TMP D:\TEMP
IF ERRORLEVEL 0 ECHO THE COPY WAS GOOD!
IF ERRORLEVEL 1 ECHO ERROR IN COPY

That is the basics of errorlevel checking. Valid numbers are 1-255. You can always errorcheck any application you have just started or network you connected to.

You can Use the GOTO command instead of ECHO to make your batch jump to a particular section to further process the error

example:

RD /S RECYCLER >NUL
IF ERRORLEVEL 1 goto :error
ECHO The delete was okay.
GOTO END

:ERROR
echo Warning, I was unable to delete!
GOTO END

:END
echo BYE!


may i know how to do the auto run?


Discussion

No Comment Found