Get file from www or ftp

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Get file from www or ftp

Post by mol » Thu Jun 18, 2009 7:38 am

I wanna ask , if somebody know how to retrieve file from internet (maybe via www, so login and password is not required)

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Thu Jun 18, 2009 8:10 am

Yes, if we know the exact address of the file/directory.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Post by mol » Thu Jun 18, 2009 9:58 am

Of course, I know concrete adress and filename to retrieve.

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Thu Jun 18, 2009 10:42 am

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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Post by mol » Thu Jun 18, 2009 11:10 am

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...

User avatar
jrendon
Posts: 92
Joined: Thu Aug 14, 2008 9:21 pm

Post by jrendon » Thu Jun 18, 2009 3:03 pm

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 ..... :mrgreen:

Regards
Juan Rendon

P.D. My english is bad, i need more practice. jejejeje

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Post by mol » Thu Jun 18, 2009 7:32 pm

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

User avatar
mol
Posts: 3247
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 230 times
Been thanked: 132 times
Contact:

Post by mol » Sat Jun 20, 2009 9:39 am

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 
Attachments
download.zip
(2.26 KiB) Downloaded 309 times

User avatar
esgici
Posts: 4517
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 391 times
Been thanked: 111 times
Contact:

Post by esgici » Sat Jun 20, 2009 10:34 am

Hi Marek

Thanks to sharing :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D

User avatar
Rathinagiri
Posts: 5264
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Has thanked: 169 times
Been thanked: 172 times
Contact:

Post by Rathinagiri » Sat Jun 20, 2009 12:19 pm

Thanks a lot for sharing. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.

Post Reply