Jump to content

Add File Name to FTP Debug


Elia
 Share

Recommended Posts

Hi All,

I need some help, I am writing a script that FTPs some files and then outputs the results, but I am unable to figure out how to output the file name on line 58. Here is the code (modified to exclude personal information):

 

  1. #include <FTPEx.au3>
  2. #include <MsgBoxConstants.au3>
  3. #include <WinAPIFiles.au3>
  4. #include <Inet.au3>
  5. #include <Debug.au3>
  6. #include <File.au3>
  7. #include <Array.au3>
  8. Local $Server = 'ftp.com'
  9. Local $Username = 'user'
  10. Local $Password = 'password'
  11. Local $LocalFolder = 'C:\Folder'
  12. Local $RemoteFolder = '/users/user1'
  13. Local $SMTPServer = "Exchange.domain.com"
  14. Local $FromName = "FTP"
  15. Local $FromAddress = "email@address.com"
  16. Local $ToAddress = " email@address.com "
  17. Local $Subject = "FTP Transfer Failed, please check server"
  18. Local $Subject1 = "FTP Connection Failed, please check server"
  19. Local $Body[2]
  20. $Body[0] = "Line 1"
  21. $Body[1] = "Line 2"
  22. Local $Body1[2]
  23. $Body1[0] = "Line 1"
  24. $Body1[1] = "Line 2"
  25. $LogFolder = "\\COMP\LOGS"
  26.  
  27. _DebugSetup ("Debug", True)
  28.  
  29. FileMove ("\\COMP\Test\*.txt", "\\COMP\FTP")
  30.  
  31. Local $FolderContents = _FileListToArray("\\COMP\FTP")
  32. Local $LogFile = "\FilesToSend_" & @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC & ".log"
  33. _FileCreate($LogFolder & $LogFile)
  34. _FileWriteFromArray($LogFolder & $LogFile, $FolderContents)
  35.  
  36. If FileExists ( "\\COMP\FTP" ) Then
  37.     Local $Open = _FTP_Open('FTP')
  38.     Local $CallBack = _FTP_SetStatusCallback($Open, 'FTPStatusCallbackHandler')
  39.     Local $Connect = _FTP_Connect($Open, $Server, $Username, $Password, 0, $INTERNET_DEFAULT_FTP_PORT, $INTERNET_SERVICE_FTP, 0, $CallBack)
  40.         If $Connect <> 0 Then
  41.             Local $Transfer = _FTP_DirPutContents($Connect, $LocalFolder, $RemoteFolder, 0)
  42.             _FTP_Close($Connect)
  43.             _FTP_Close($Open)
  44.                 Else
  45.             _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject1, $Body, "EHLO" & @ComputerName, -1)
  46.         EndIf
  47.             If $Transfer = 1 Then
  48.                 FileMove ( "\\COMP\FTP\*.txt", "\\COMP\Test\SENT")
  49.                 Else
  50.                 _INetSmtpMail($SMTPServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body1, "EHLO" & @ComputerName, -1)
  51.             EndIf
  52. EndIf
  53. Func FTPStatusCallbackHandler($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength)
  54.                     #forceref $hInternet, $iContext
  55.                     If $iInternetStatus = $INTERNET_STATUS_REQUEST_SENT or $iInternetStatus = $INTERNET_STATUS_RESPONSE_RECEIVED Then
  56.                         Local $iBytesRead
  57.                         Local $tStatus = DllStructCreate('dword')
  58.                         _WinAPI_ReadProcessMemory(_WinAPI_GetCurrentProcess(), $pStatusInformation, $tStatus, $iStatusInformationLength, $iBytesRead)
  59.                         _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus) & ' | Size = ' & DllStructGetData($tStatus, 1) & ' Bytes    Bytes read = ' & $iBytesRead)
  60.                     Else
  61.                         _DebugOut(_FTP_DecodeInternetStatus($iInternetStatus))
  62.                     EndIf
  63.                     EndFunc

I would like the output on line 58 to include a file name, at the moment it only displays the size of the file and Bytes read. Here is what is currently outputted:

Handle created
Resolving name ...
Name resolved
Connecting to server ...
Connected to server
Receiving response ...
Response received | Size = 58 Bytes    Bytes read = 4
Sending request ...
Request sent | Size = 13 Bytes    Bytes read = 4
Receiving response ...
Response received | Size = 20 Bytes    Bytes read = 4
Sending request ...
Request sent | Size = 19 Bytes    Bytes read = 4
Receiving response ...
Response received | Size = 20 Bytes    Bytes read = 4
Handle created
Handle created
Handle created
Handle created
Handle created
Closing connection ...
Connection closed
Handle closing ...

Any help would be greatly appreciated! :)

Thanks.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...