Page 1 of 2
Get file from www or ftp
Posted: Thu Jun 18, 2009 7:38 am
by mol
I wanna ask , if somebody know how to retrieve file from internet (maybe via www, so login and password is not required)
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 8:10 am
by Rathinagiri
Yes, if we know the exact address of the file/directory.
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 9:58 am
by mol
Of course, I know concrete adress and filename to retrieve.
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 10:42 am
by Rathinagiri
Then you can get the file using a download manager like flashget or if you use firefox there are large number of extensions for downloading by giving the url.
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 11:10 am
by mol
But....
I wanne build something like autoupdate - my program will test if there is new version on internet and - if newer exists - downloads it and run installation.
So, I need to download new setup file directly from my application - I've tested hyperlink - it works, but in this case user action is required...
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 3:03 pm
by jrendon
mol wrote:But....
I wanne build something like autoupdate - my program will test if there is new version on internet and - if newer exists - downloads it and run installation.
So, I need to download new setup file directly from my application - I've tested hyperlink - it works, but in this case user action is required...
I'm use wget for windows for update my program's with execute command on minimized window.
1.- with my update program execute the wget on minimized window and i get a file in txt
2.- I read the file txt and check the version on internet
3.- If the version is new then with wget download the new version on temp folder
4.- when the file is downloaded then close the main program and replace the new program.
5.- Listo .....
Regards
Juan Rendon
P.D. My english is bad, i need more practice. jejejeje
Re: Get file from www or ftp
Posted: Thu Jun 18, 2009 7:32 pm
by mol
Thanks for your suggestion. I'll try to implement it tomorrow.
Marek
I want to renew this topic.
I think installing wget is not the best way...
It works, but - on each computer running my application I need to install wget - it's hard to realize.
Maybe another idea?
I watched for samples linked with MINIGUI Extended - FTPClient - but I don't know how to use it ("ftpclient" doesn't want to compile with Minigui Ext.)
Regards, Marek
Re: Get file from www or ftp
Posted: Sat Jun 20, 2009 9:39 am
by mol
Success!!!
Two days of searching ant testing and I've compiled from everything I found, small function that is really BIG! I wanna share it with us, maybe it will be useful!
I wanna put working example with this function.
Code: Select all
PROCEDURE DownloadFromWWW
param cURL, cLocalFileName
LOCAL oCon, oUrl, i
cLocalFileName := alltrim(cLocalFileName)
oUrl := tURL():New( cUrl )
IF Empty( oUrl )
MsgBox("Invalid url " + cUrl)
return
ENDIF
IF oUrl:cProto != "http"
MsgBox('This is a header test for http. Use an http address.')
return
END
oCon := TipClientHttp():New( oUrl )
oCon:nConnTimeout := 20000
MsgBox("Connecting with "+ oUrl:cServer)
IF oCon:Open( cUrl )
MsgBox("Connection eshtablished." +chr(10)+"Press OK to retrieve" + oUrl:cPath +oUrl:cFile)
oCon:WriteAll(cLocalFileName)
MsgBox("Downloaded...")
oCon:Close()
ELSE
MsgBox("Can't connect with "+ oUrl:cServer)
IF oCon:SocketCon == NIL
MsgBox("Connection not initiated")
ELSEIF hb_InetErrorCode( oCon:SocketCon ) == 0
MsgBox("Server sayed: "+ oCon:cReply)
ELSE
MsgBox("Error in connection: " + hb_InetErrorDesc( oCon:SocketCon ))
ENDIF
END
RETURN
Re: Get file from www or ftp
Posted: Sat Jun 20, 2009 10:34 am
by esgici
Hi Marek
Thanks to sharing
Regards
--
Esgici
Re: Get file from www or ftp
Posted: Sat Jun 20, 2009 12:19 pm
by Rathinagiri
Thanks a lot for sharing.