Jump to content

_FTP_FileOpen Windows 8.1 doesn't work


Go to solution Solved by TouchOdeath,

Recommended Posts

#include <FTPEx.au3>

func ftpflread($server, $usern, $pass, $flnm)   
Local $Open = _FTP_Open('x')
    Local $connect = _FTP_Connect($Open, $server, $usern, $pass)
    Local $flopen = _FTP_FileOpen($connect, $flnm)
    Local $flread = StringSplit(_HexToString(_FTP_FileRead($flopen, 20000)), @CR)
    _FTP_Close($flopen)
    _ArrayDelete($flread, 0) ;array 0 has count, remove count
    _ArrayDisplay($flread,'readarr')
    Return $flread
endfunc

On Windows 7 Ultimate 64 bit, it works great, returns a nice array.  Windows 8.1 Pro 64-bit (all settings default) running on Virtualbox version 4.3.18 r96516 hangs on _FTP_FileOpen.  If I disable windows firewall, it still hangs.  If I leave the firewall enabled and add an exception to my script, it passes completely through and returns:

Row|Col 0

[0]|0x0
 
I have internet, I can open up google and do a search.
 
Before I even came up with the code above, I created a DOS ftp that returned an array also, it also worked with windows 7 but hung with Windows 8.1 also.  It uses this exe:  C:WindowsSystem32ftp.exe
 
Has anyone else came across this?
 
EDIT:
 
Heres a second function that works great in windows 7 but not 8.1:
#include <FTPEx.au3>
#include <File.au3>
#include <Array.au3>

func ftpflread($server, $usern, $pass, $flnm)
local $flnmlocation = @TempDir & "\" & $flnm, $readar[500]
InetGet("ftp://" & $usern & ":" & $pass & "@" & $server & "/" & $flnm, $flnmlocation, 1, 0)
_FileReadToArray($flnmlocation,$readar)
FileDelete($flnmlocation)
_ArrayDelete($readar, 0) ;array 0 has count, remove count
;_ArrayDisplay($readar,'j')
Return $readar
EndFunc

 

EDIT2:

I ended up creating a .NET app that works flawlessly for both Windows 7 and 8.1, I would much rather have an autoit solution, so the problem still remains.  I'll format the code for the forum and post here later....

EDIT3:

Yet another.... win7 works great win8.1 doesnt work:

#include <Inet.au3>
#include <Array.au3>
ftpflread("ftp.someftp.com","yourusername","yourpass","yourfile.txt")

func ftpflread($server, $usern, $pass, $flnm)
    local $ar = StringSplit(_INetGetSource("ftp://" & $usern & ":" & $pass & "@" & $server & "/" & $flnm),@CR)
    _ArrayDelete($ar,0)
;_ArrayDisplay($ar,'j')
Return $ar
EndFunc
Edited by TouchOdeath
Link to comment
Share on other sites

  • Solution

SOLUTION:

#include <IE.au3>
#include <Array.au3>

;NOTES:
;$server, $usern, and $pass are subject to URL encoding (http://www.w3schools.com/tags/ref_urlencode.asp)
;the stripping of excess HTML probably depends on your version of IE, I have only tested with IE11
ftpflread("ftp.someftp.com","yourusername","yourpass","yourfile.txt")

func ftpflread($server, $usern, $pass, $flnm)
Local $oIE = _IECreate("ftp://" & $usern & ":" & $pass & "@" & $server & "/" & $flnm,0,0,1) ;hidden window
Local $sHTML = _IEDocReadHTML($oIE)
WinClose("ftp://" & $server & "/" & $flnm & " - Internet Explorer","")
$sHTML = StringReplace($sHTML,"<html><head></head><body><pre>","")
$sHTML = StringSplit(StringReplace($sHTML,"</pre></body></html>",""),__HexToString("0x0a"))
_ArrayDelete($sHTML,0)
;_ArrayDisplay($sHTML,'')
Return $sHTML
EndFunc

Func __HexToString($sString)
    If StringLeft($sString, 2) <> "0x" Then $sString = "0x" & $sString
    Return BinaryToString($sString)
EndFunc

Not as clean as I wanted, but it sure is cleaner than the .NET app, and it works with both windows 7 and 8.1  IE11.  I haven't tested any other version of IE.  Hopefully this thread helps somebody....

The original problem with _ftp_Open, InetGet, and _InetGetSource has not been solved but atleast the problem has been brought forth.

Edited by TouchOdeath
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...