Avatar of jdn717
jdn717
 asked on

WS_FTP Script "Connect Failure" Handling

Whats an appropriate way of handling a connection failure in ws_ftp script?  I have a job that runs nightly and Im not sure what to do below. My manager just gave me this task and Im not familiar with the keywords.

This is the code in the .scp file that is passed into the ftpscrpt application via a .bat file.  The connection failure takes places at line 3, of course :)  How should I handle this issue? Increase the timeout? A loop?

LOG E:\BatchProcesses\ReceivedFiles\RiskImport\RiskImportXML.log
TRACE Screen
CONNECT TBI!RiskImport
ONERROR GOTO DISCONNECT
MGET *.pgp E:\BatchProcesses\ReceivedFiles\RiskImport\Files\
LABEL FILEDELETE
MDELETE *.PGP
LABEL DISCONNECT
CLOSE

Open in new window

Windows Batch

Avatar of undefined
Last Comment
Bill Prew

8/22/2022 - Mon
Bill Prew

What does the log show when the CONNECT fails?  Does it fail all the time, or only occasionally?

If it's the case that the server can be down sometimes when the script runs, you could add a PING in the BAT script before the WSFTP execution, and let it loop until the server responds to a PING.

~bp
jdn717

ASKER
Heres the log.  It usually connects just fine.  Would you mind explaining that PING solution you mentioned. That sounds interesting.

E:\BatchProcesses\ReceivedFiles\RiskImport>ECHO OFF 
Processing Line 1 [LOG E:\BatchProcesses\ReceivedFiles\RiskImport\RiskImportXML.log]  Processing Line 2 [TRACE Screen] 
Processing Line 3 [CONNECT TBI!RiskImport] Finding Host ftp.tnwinc.com ... [2012.07.06 03:00:15.662] Connecting to 67.202.192.115:21 [2012.07.06 03:00:16.834] Connect failure Failure in command [CONNECT TBI!RiskImport]  
Processing Line 4 [ONERROR GOTO DISCONNECT] Set [ONERROR] action to [GOTO DISCONNECT]  Processing Line 5 [MGET *.pgp E:\BatchProcesses\ReceivedFiles\RiskImport\Files\] Not Connected Failure in command [MGET *.pgp E:\BatchProcesses\ReceivedFiles\RiskImport\Files\] 
Processing command [ONERROR GOTO DISCONNECT] at line 4 
Processing Line 4 [GOTO DISCONNECT] Jump to command [LABEL DISCONNECT] at line 8 Set [ONERROR] action to [CONTINUE ]  
Processing Line 8 [LABEL DISCONNECT]  Processing Line 9 [CLOSE]

Open in new window

jdn717

ASKER
This is the first part of the bat.

ECHO OFF

REM Risk Upload XML Download

rem Upload the File
cd c:\Program Files (x86)\Ipswitch\WS_FTP 12\

"c:\Program Files (x86)\Ipswitch\WS_FTP 12\ftpscrpt" -f E:\BatchProcesses\ReceivedFiles\RiskImport\RiskUploadXML.scp
if errorlevel 1 goto :Error

Open in new window

All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
Bill Prew

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bill Prew

Also, you will want to change the 6000 to 60000 in the second PING which is just used as a delay technique.  I had lowered it to 6 seconded during some testing here.

~bp
jdn717

ASKER
Yeah, I think this is going to work.  I tested it and I am getting satisfactory results.  My fortay isnt script so I appreciate the help.
Bill Prew

Welcome, hope that works out for you.  Thanks for the feedback.

~bp
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.