Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I’m writing a batch script (running on a w/2000 pc) that executes an ftp to send messages to a corporate server. How do I check to ensure the FTP completed successfully? See Below:
myftp.bat:
ECHO OFF
ftp -s:scsend.scr
>> WHAT GOES HERE ??scsend.scr
open 999.95.232.130
userid
password
cd send
lcd c:\data\outbound_data
binary
prompt
dir
put senddata.txt

During the FTP session, various messages are outputted. Let's suppose that the most vital command on your FTP session is that PUT cmd, and let's also suppose that it returns the message "file sent successfully" when it goes OK. Let's also suppose such message has no chance of being outputed if the FTP session fails. Then, all you gotta do is:
ftp -s:scsend.scr |FIND "file sent successfully" > nul
if errorlevel=1 goto errorecho FTP session successful!
goto end:error
echo FTP session not completed!
goto end:end
The idea is looking for a certain string that will appear only if the FTP session was successful, and will not appear if it fails, or vice-versa.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br__________________________________________________________

When the FTP completes successfully the FIND command searching for string "RNTO command successful" generates a success transmission message. IT works when IT works...
However, when I direct the FTP script to an unauthorized IP address (to force a failure condition), the FIND message did not detect the fault, it did not echo a the failure message. It doesn't work when it doesn't.
Is there any way to display (or store to a file) the script activity messages? (prior to the addition of the find command, they appeared on the screen)
See Below:
NEW FTP BAT FILE (ftp script unchanged):
ECHO OFF
cd c:\edi\outbound_edi
del sendedi.txt
copy /b *out* + *997* sendedi.txt
cd c:\edi\scripts\prod
ftp -s:scsend.scr|FIND "RNTO command successful"
if errorlevel 1 goto errormsg
ECHO EDI SEND SUCCESSFUL
goto end
:errormsg
ECHO >> FTP FAILED CHECK LOGS myftp.batC:\EDI\scripts\prod>ECHO OFF
outtestdata15.txt
1 file(s) copied.
> ftp: connect :Connection timed out

Continued......
NEW MYFTP.bat
ECHO OFF
cd c:\edi\outbound_edi
del sendedi.txt
copy /b *out* + *997* sendedi.txt
cd c:\edi\scripts\prod
ftp -s:scsend.scr|FIND "RNTO command successful"
if errorlevel 1 goto errormsg
ECHO EDI SEND SUCCESSFUL
goto end
:errormsg
ECHO >> FTP FAILED CHECK LOGS mftp.batC:\EDI\scripts\prod>ECHO OFF
outtestdata15.txt
1 file(s) copied.
> ftp: connect :Connection timed out

![]() |
Help with Bat file
|
dos script
|

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