Recent

Author Topic: (SOLVED) Is there anybody using FTP client (Indy ou Lnet)  (Read 16299 times)

sinfoni

  • Jr. Member
  • **
  • Posts: 56
(SOLVED) Is there anybody using FTP client (Indy ou Lnet)
« on: June 24, 2010, 07:04:23 am »
Hi all,

I'm trying to make a console program (Mac OS X) which has to download a file from a FTP server. I've tried Indy and Lnet. With both, I just get empty file (0 kb).

Of course I have verified that the file to download is present, etc. I can download it using FileZilla with same host, user and password.

Any Idea ?

André
« Last Edit: June 26, 2010, 01:29:09 am by sinfoni »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Is there anybody using FTP client (Indy ou Lnet)
« Reply #1 on: June 24, 2010, 08:17:00 am »
sinfoni, the example code (using LNet) would be useful.

I've written once a simple MacOSX FTP client front-end for external 'ftp' tool. Quite cheap solution :)

sinfoni

  • Jr. Member
  • **
  • Posts: 56
Re: Is there anybody using FTP client (Indy ou Lnet)
« Reply #2 on: June 24, 2010, 08:34:36 am »
Yes, it's ok. :) As I've began my FTP client using Indy, then Lnet because of Indy does not work, but still get empty file, I thought the... truth was out there.

I've compiled and used successfully the Lnet ftp example, and now, mine is also ok.

Thanks.

fredycc

  • Sr. Member
  • ****
  • Posts: 264
Re: Is there anybody using FTP client (Indy ou Lnet)
« Reply #3 on: June 24, 2010, 11:34:39 am »
Hi, this is a little piece of code, thats download a file from a ftp server. This works with Indy 10.2.0.3, I have test this in linux and windows, and works.

First, obtaint the list of files, in this case zip, only.

Quote
   
     FTP := TIdFTP.Create( nil );
     FTP.Username := 'user123';
     FTP.Password := 'pas123';
     FTP.Host := 'xxx.xxx.xxx.xxx';
     try
        aLog('Intentando conectar para recuperar lista de archivos...');
        FTP.Connect;
        aLog('Conexión establecida.');
     except

           aLog(DateTimeToStr(Now) + '  No se logro establecer la conexión con el servidor FTP.');
           FTP.Free;
           Terminate;

     end;

     FTP.ChangeDir( '/myfiles/' );
     FTP.List('*.ZIP',true);

     numFiles := FTP.DirectoryListing.Count;

     SetLength(aFilesftp, numFiles);

     for I:= 0 to numFiles - 1 do
         aFilesftp := FTP.DirectoryListing.Items.FileName;

     FTP.Disconnect;  

After choose a file, get it.
    
Quote
    FTP.Get( FileName , CurrDir+'\bk\'+FileName, False, False );
     RenameFile := Filename + '.down';
     FTP.Rename ( FileName, RenameFile );

     FTP.Disconnect;    
« Last Edit: June 24, 2010, 12:52:43 pm by fredycc »

sinfoni

  • Jr. Member
  • **
  • Posts: 56
Re: Is there anybody using FTP client (Indy ou Lnet)
« Reply #4 on: June 26, 2010, 01:27:59 am »
Thanks redycc, but IdFTP definitly doesn't work with Mac OS X.

Note that the IdHttp component has also some problems with Mac OS X. I use it, but I have to free it then recreate it before each connexion, otherwise an exception occurs.

Indy is very unstable for this platform. Moreover, it's annoying, but IdFTP component triggers exception on success. I can't understand this behavior (neither agree with it).

I still use it only for windows/delphi environment.   
André.

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
Re: (SOLVED) Is there anybody using FTP client (Indy ou Lnet)
« Reply #5 on: July 03, 2010, 03:31:18 pm »
What widgetset are you using with lNet/Lazarus? Are you using "visual" (the ones placed on form in visual editor) lNet components?

If you're using the cocoa/carbon widgetsets lNet will not register network events. I don't own a mac and virtualbox still doesn't work properly with hackintosh so I can't make carbon interface hookup into lNet. If this is your case you must use the "non-visual" (TLTcp etc.) components directly from the lNet/lftp units and make a .CallAction call when possible to "look for events" on the sockets. (you can use a timer for this for example, or OnIdle).

It's not the best solution on a visual project, but it'll work.

sinfoni

  • Jr. Member
  • **
  • Posts: 56
Re: (SOLVED) Is there anybody using FTP client (Indy ou Lnet)
« Reply #6 on: July 03, 2010, 05:55:12 pm »
As I said, I succed in making Lnet working. I don't use visual components because my processud is a daemon.

The problem was that i forgot the OnControl trigger. Now the OnReceive fires when I call CallAction.

Thanks

 

TinyPortal © 2005-2018