>Melissa, is there any way to verify the return status using this format?
Yes, there is, but it is a little tricky. First, you will need to know all the 3 digit FTP status codes. These can be found in
RFC595, the FTP RFC. Look at section 4.2, reading that will help you understand the ordering of the codes. At the end of that section is a listing of all the status codes.
In order to be able to programatically check these codes, you will need to redirect the output of the FTP session to a file. That means you would change your FTP command line from:
! ftp -s:ftp.txt
to:
! ftp -s:ftp.txt > ftplog.txt
where ftp.txt is your script file and ftplog.txt is the file which will store the output of the FTP session. Note that the > redirect creates a new file. If you wish to append to a file, use the >> redirect. Creating a new file each time is probably simplier in the long run. You can log an desired results in a table when you parse the file.
Typically the code is the first 3 characters on the line, but make sure to parse out the FTP prompt as well. You will most likely want to know if a file has been sucessfully transferred. A successful transfer is marked by a pair of codes. First there is a 125 or a 150 code at the start of the transfer. If the transfer is successful, the next code should be 226. Otherwise, an error has occurred in the transfer. What I monitor for as error codes are 450, 550, 451, 551, 452, 552 and 553. You can monitor for more if you wish, just add them to the case statement or put them in a table. A simplified version to check follows below using a case statement to get the error messages. You will have to see what your FTP program outputs in the text file to be able to parse for file names and file sizes.
Do While !FEOF(nLogFile)
cData = FGetS(nLogFile)
cCode = Substr(Alltrim(Strtran(cData, 'ftp> ', '')), 1, 3)
Do Case
Case cCode = "425"
cMess = "Error opening connection."
Case cCode = "125" or cCode = "150"
cData = FGetS(nLogFile)
cCode = Substr(Alltrim(Strtran(cData, 'ftp> ', '')), 1, 3)
If cCode = "226"
cMess = "Transfer complete."
Else
cMess = FTPError(cCode)
EndIf
Otherwise
cMess = FTPError(cCode)
EndCase
If !Empty(cMess)
Wait Window "FTP: "+cMess Timeout 5
EndIf
EndDo
Function FTPError
Parameter cCode
Private cMessage
Do Case
Case cCode = "450"
cMessage = "File in use."
Case cCode = "550"
cMessage = "File not found or no file access."
Case lcCode = "451"
cMessage = "Local error in processing."
Case lcCode = "551"
cMessage = "Page type unknown."
Case lcCode = "452"
cMessage = "Insufficient disk space."
Case lcCode = "552"
cMessage = "Exceeded disk space allocation."
Case lcCode = "553"
cMessage = "File name not allowed."
Otherwise
cMessage = ""
EndCase
Return cMessage
Melissa Danforth
Customsoft Corporation