DataFlex
DataFlex
Capture the FTP Session Log
See more FTP Examples
Demonstrates the SessionLog property (with KeepSessionLog), which holds the in-memory FTP protocol conversation — commands and server replies — collected during the session.
Background: When an FTP operation fails for a non-obvious reason, the exact command/reply exchange is the most useful diagnostic there is, and
SessionLog captures it verbatim once KeepSessionLog is enabled. Passwords are omitted, so it is safe to log or attach to a bug report. Over a long session it grows without bound; clear it with ClearSessionLog to bound memory or to isolate the log for one operation.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
Set ComPassword Of hoFtp To "myPassword"
// Keep an in-memory log of the FTP protocol conversation for troubleshooting. Passwords are
// not recorded in it.
Set ComKeepSessionLog Of hoFtp To True
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComChangeRemoteDir Of hoFtp "public_html" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// The SessionLog contains the protocol commands and server replies collected so far.
Get ComSessionLog Of hoFtp To sTemp1
Showln sTemp1
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure