Computing.Net > Forums > Disk Operating System > FTP SCRIPTING & ERROR CAPTURING

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.

FTP SCRIPTING & ERROR CAPTURING

Reply to Message Icon

Name: regstour
Date: July 17, 2003 at 08:44:18 Pacific
OS: w/2000
CPU/Ram: 768
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: July 17, 2003 at 11:49:23 Pacific
Reply:

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 error

echo 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

__________________________________________________________


0

Response Number 2
Name: regstour
Date: July 17, 2003 at 12:50:42 Pacific
Reply:

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

C:\EDI\scripts\prod>ECHO OFF
outtestdata15.txt
1 file(s) copied.
> ftp: connect :Connection timed out



0

Response Number 3
Name: regstour
Date: July 17, 2003 at 12:56:50 Pacific
Reply:

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

C:\EDI\scripts\prod>ECHO OFF
outtestdata15.txt
1 file(s) copied.
> ftp: connect :Connection timed out


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Help with Bat file dos script



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: FTP SCRIPTING & ERROR CAPTURING

DOS FTP Script www.computing.net/answers/dos/dos-ftp-script-/11678.html

FTP error 421 www.computing.net/answers/dos/ftp-error-421/13018.html

DOS Batch file to FTP files from UNIX www.computing.net/answers/dos/dos-batch-file-to-ftp-files-from-unix/2105.html