Jewtus

Downloading using FTP

5 posts in this topic

#1 ·  Posted

I've been trying to figure out the ftp UDF but it doesn't seem to work for me, so I started looking at some other alternatives that are supposed to work with ftp. I'm using the Mozilla FTP as a test URL but I can't seem to get this script to actually download the file to the local machine. Am I doing something wrong?

GetfromFTP("ftp.mozilla.org/bundles/msn/us/win32/en-US/Firefox%20Setup.exe")

Func GetfromFTP($sURL,$sUsername='',$sPassword='' )
    local $sFilePath=@TempDir&"\",$digits=20,$fn,$aSpace[3]
    For $i=1 to $digits
        $aSpace[0]=Chr(Random(48,57,1));0-9
        $aSpace[1]=Chr(Random(97,122,1));a-z
        $aSpace[2]=Chr(Random(65,90,1));A-Z
        $fn &= $aSpace[Random(0,2,1)]
    Next
    $sFilePath=$sFilePath&$fn&StringRight($sURL,4)
    If $sUsername='' AND $sPassword='' then
        InetGet("ftp://"&$sURL&"/", $sFilePath, 1)
    Else
        InetGet("ftp://"&$sUsername&":"&$sPassword&"@"&$sURL&"/", $sFilePath, 1)
    EndIf
    MsgBox(0,"",$sFilePath)
    FileDelete($sFilePath)
EndFunc

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

I can't seem to access "ftp.mozilla.org" with a ftp protocol. I can however access it with http or https protocol.

This works no problem for me:

InetGet("https://ftp.mozilla.org/bundles/msn/us/win32/en-US/Firefox%20Setup.exe", @TempDir&"\")

 

Share this post


Link to post
Share on other sites

#3 ·  Posted

Well, that is odd. I tried your line of code and it executes without error, but no file is actually saved to the temp dir.

 

I'm using Windows 10 (I don't know if that matters).

Share this post


Link to post
Share on other sites

#4 ·  Posted

Sorry i changed the path to the one you were using. I believe you need to specify the filename also. So something like:

@TempDir&"\file.exe"

 

Share this post


Link to post
Share on other sites

#5 ·  Posted

... that should have be obvious to me... sorry

 

Thanks! That does seem to work... Now I'll just have to try with SFTP...

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