WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stanl on January 27, 2014, 05:50:08 PM

Title: FTP get failure message
Post by: stanl on January 27, 2014, 05:50:08 PM
Two weeks ago I wrote a simple FTP get/put for multiple files based on examples in the help file for Wininit Extender. Got an IM from a fellow worker who was using it tonight and while the put worked, the get gave the iFTPGet Failed message.

Code (WINBATCH) Select

If getfile==0 Then Display(5,"Error","iFtpGet Failed on File: %remote_srcfile%":@CRLF:"FileSize: ":fSize)


The script has an error handler; it closes down the connection, displays the error and exits, but that line doesn't generate an error. So, if I assume the failure is a minor error such as a timeout, or a large file size is there a way to detect additional info about the failure, as maybe that is just one file out of many.

Hope this makes sense
Title: Re: FTP get failure message
Post by: Deana on January 28, 2014, 08:08:02 AM
Yes. You need to call iGetLastError. See Also iGetResponse.

Code (winbatch) Select
rslt=iFtpPut(conhandle, "C:\temp\abc.txt","temp/abc.test",0,@ASCII, @TRUE)
If rslt==0
   lasterr = iGetLastError()
   lastresp = iGetResponse()
   Message("iFtpPut Last Error: %lasterr%", lastresp)
EndIf
Title: Re: FTP get failure message
Post by: stanl on January 28, 2014, 09:57:54 AM
Thanks.
Title: Re: FTP get failure message
Post by: DAG_P6 on January 28, 2014, 10:57:02 PM
IMO, you should always check and parse the FTP response, and don't call it good unless the response so indicates.  iGetResponse returns a string, of which the first three characters are a standard FTP status code.

The following code snippet gets the response and extracts the status code from it, and converts it to an integer.

Code (winbatch) Select
rLastResultCode = Int ( StrSub ( iGetResponse() , 1 , 3 ) )

I've attached a WIL #include file, FormatFTPResponse_P6C.WIL, which contains a like named User Defined Function, FormatFTPResponse_P6C(), that cleans up the text portion of the response.
Title: Re: FTP get failure message
Post by: stanl on January 29, 2014, 08:23:10 AM
Thanks again. As it turns out, it was my bad. I was in a hurry and sought out the remote folder with iLoc rather than iFtp.

As of lates last night the compiled script worked perfectly to both send and receive.
Title: Re: FTP get failure message
Post by: DAG_P6 on January 29, 2014, 05:18:20 PM
Quote from: stanl on January 29, 2014, 08:23:10 AM
Thanks again. As it turns out, it was my bad. I was in a hurry and sought out the remote folder with iLoc rather than iFtp.

As of lates last night the compiled script worked perfectly to both send and receive.

You are welcome,. Sir!