QA Stooge Posted March 29, 2010 Posted March 29, 2010 (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 NextAnd 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 March 29, 2010 by QA Stooge
ProgAndy Posted March 29, 2010 Posted March 29, 2010 (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 March 30, 2010 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
QA Stooge Posted March 29, 2010 Author Posted March 29, 2010 (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 March 29, 2010 by QA Stooge
JohnOne Posted March 29, 2010 Posted March 29, 2010 Well you have acheived your goal. But I can assure you that your code is "relying on the DLLs (directly or indirectly)" Glad you got it sorted. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now