Sign in to follow this  
Followers 0
QA Stooge

DLL-free FTP?

4 posts in this topic

#1 ·  Posted (edited)

I guess the topic says it all.

Do the Auto-it base functions provide a way to perform an FTP POST without relying on the DLLs (directly or indirectly)? Here's a simple chunk of my code.

$PortLine = "PASV"
    $portResults = TEDFTPOperation($mySock, $PortLine)
    if Int(StringLeft($portResults,1)) <> 2 then
        ConsoleWrite("OOPS!")
    EndIf
    $sent = TEDFTPOperation($mySock, "STOR "&$myFile2Send, 2048, FileGetSize(@WorkingDir&"\"&$myFile2Send)*10)
    for $i = 1 to 15 
        $lst = TEDFTPListen($mySock)
        ConsoleWrite($i&": "&$lst)
        if StringInStr($lst,"425")>0 then 
            ConsoleWrite("send failed")
            ExitLoop
        EndIf
    Next
And here's the relevant portion of the log on the server.

(000148) 3/29/2010 12:11:12 PM - qa1_ch (172.19.197.25)> 227 Entering Passive Mode (172,19,197,39,234,195)

(000148) 3/29/2010 12:11:12 PM - qa1_ch (172.19.197.25)> STOR Harness.21p

(000148) 3/29/2010 12:11:22 PM - qa1_ch (172.19.197.25)> 425 Can't open data connection.

It seems obvious to me that I'm missing the actual transfer of the file itself (note the delay in time... 10 seconds before the "425" results).

So far, I've tried...

  • TCPSend($mySock,FileRead(@WorkingDir&"\"&$myFile2Send))
  • FileCopy(@WorkingDir&"\"&$myFile2Send, "ftp:\\"&$IPserver&":"&$myPort)
  • ConsoleWrite("@@@"&StdinWrite($mySock,FileRead(@WorkingDir&"\"&$myFile2Send)))
And it didn't get me anywhere.

Any other options I haven't tried?

Edited by QA Stooge

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

AutoIt always uses DLLs. Even the standard TCP-functions rely on functions of the Windows-API. It really would be easier to use the WinHTTP / WinInet-DLLs to access an FTP-Server, but of course you can create a plain implementation. Documentation is here (includes links to the underlying RFCs) I just don't see a reason to do that when MS has already done it for you.

*Fixed typos*

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Aha!

Well it seems I've found my own answer.

TEDFTPOperation($mySock, "TYPE I")
    
    $NextConn = TEDFTPOperation($mySock, "PASV")
    $dcAddr = StringSplit(TEDFTPaddressTranslate(TEDFTPAddressExtract($NextConn)),":")
    Local $dataConn = TCPConnect($dcAddr[1],$dcAddr[2])
    $sent = TEDFTPOperation($mySock, "STOR "&$myFile2Send)
    TCPSend($dataConn,FileRead(@WorkingDir&"\"&$myFile2Send))
    TCPCloseSocket($dataConn)
Works great for what I needed. Edited by QA Stooge

Share this post


Link to post
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
Sign in to follow this  
Followers 0