1. Using the 'FtpCommand' of wininet.dll

Hello everybody. I am trying to use the library of "Wrapper for Wininet.dll"posted on contributions from users, of Fabio Ramires.

But the "FtpCommand" with the file 19FTPCommand.exw example, is not working. Within the code, in its comments, Mister Fabio warns that some functions may not work depending on the version of the file WININET.DLL, however, already tested with win98 versions, Millennium, and XP, but still not working (does not return results).

I need this function to obtain the information contained in directories from an FTP server to know what are the folders and files in the directory current. But, the program returns an empty string.

Please, someone had a code worked well, with this function? or otherwise, how can I make this program work correctly

Thank you very much.

new topic     » topic index » view message » categorize

2. Re: Using the 'FtpCommand' of wininet.dll

I think the problem might be that Fabio's example is trying to log in as 'fabio' to localhost, so unless your configuration matches, you'll get an error. I changed the server to WinZip's anonymous FTP site...

include EInetLib.ew
 
integer res 
 
atom ses1, con1, han1 
 
ses1 = InternetOpen({}) 
 
con1 = InternetConnect({ 
  {"session_id",ses1}, 
  {"server_name","ftp.winzip.com"}, 
  {"service","FTP"}, 
  {"user_name","anonymous"}, 
  {"password","someone@example.com"} 
  }) 
 
if con1 then -- The FTP connection could be stablished 
 
  Msg(InternetGetLastResponseInfo()) 
 
  -- Since in this case we expect a response FtpCommand returns 
  -- a Internet file handle that can be used to read the response 
  han1 = FtpCommand({ 
                       {"connection_handle" ,con1}, 
                       {"expect_response",TRUE},  
                       {"command","LIST"}, 
                       {"flags","ASCII"} 
                    }) 
                    
  Msg(InternetGetLastResponseInfo()) -- this is normal server response 
 
  -- Now let's read what the server sends 
  -- For simplicity we are just going to  
  -- read the first 4096 bytes of LIST given by server 
  Msg(InternetReadFile(han1, 4096))  
   
else  
  Msg(net_err_msg) 
end if 
 
res = InternetClose(ses1) 
Wininet
220 spftp/1.0.0000 Server [81.52.134.149]
331 Password required for USER.
230 Welcome to WinZip's FTP site.
Wininet
200 TYPE set to A.
200 PORT command successful.
150 Opening ASCII mode data connection for /.
Wininet
drwxrwxr-x   1     1994     1994        0 Jul  2 13:42 german
drwxrwxr-x   1     1994     1994        0 Apr  9  2003 pub
-rw-rw-r--   1     1994     1994       33 Apr 11  2003 welcome.msg
-rw-rw-r--   1     1994     1994  6686208 Oct 17  2008 winzip111es.msi
-rw-rw-r--   1     1994     1994  6727680 Oct 17  2008 winzip111fr.msi
-rw-rw-r--   1     1994     1994  6661120 Jun 29  2007 winzip111jp.msi
-rw-rw-r--   1     1994     1994  6628864 Nov 26  2007 winzip111zh.msi
-rw-rw-r--   1     1994     1994  7412224 Oct 17  2008 winzip112ru.msi
-rw-rw-r--   1     1994     1994 13194592 Jan 15  2009 winzip120.exe
-rw-rw-r--   1     1994     1994  8036352 Jan 15  2009 winzip120.msi
-rw-rw-r--   1     1994     1994  9221472 Mar 27 19:59 winzip120es.exe
-rw-rw-r--   1     1994     1994  8232448 Mar 27 20:01 winzip120es.msi
-rw-rw-r--   1     1994     1994  9287008 Feb 19  2009 winzip120fr.exe
-rw-rw-r--   1     1994     1994  8293376 Jan 21  2009 winzip120fr.msi
-rw-rw-r--   1     1994     1994  8231424 Apr 24 14:02 winzip120jp.msi
-rw-rw-r--   1     1994     1994 13727048 Jun 29 18:09 winzip121.exe
-rw-rw-r--   1     1994     1994  8436224 Jun 15 14:43 winzip121.msi
-rw-rw-r--   1     1994     1994  9749832 Jul 14 15:03 winzip121es.exe
-rw-rw-r--   1     1994     1994  8617984 Jul 14 15:04 winzip121es.msi
-rw-rw-r--   1     1994     1994  9807176 Jul 15 14:54 winzip121fr.exe
-rw-rw-r--   1     1994     1994  8673792 Jul 15 14:55 winzip121fr.msi
-rw-rw-r--   1     1994     1994  3327360 Nov 26  2007 winzipemailcomp20.exe
-rw-rw-r--   1     1994     1994   404480 Nov 14  2006 wz7245.msp
-rw-rw-r--   1     1994     1994   657056 Feb 23  2006 wzcline20.exe
-rw-rw-r--   1     1994     1994   959896 Aug 16  2007 wzcline22.exe
-rw-rw-r--   1     1994     1994  1041816 Sep 10  2008 wzcline23.exe
-rw-rw-r--   1     1994     1994  1119640 Sep 10  2008 wzcline30.exe
-rw-rw-r--   1     1994     1994  1140096 Jun 15 20:33 wzcline31.exe
-rw-rw-r--   1     1994     1994   734400 Feb 23  2005 wzcou10.exe
-rw-rw-r--   1     1994     1994  2131320 Jul 24  2007 wzipse31.exe
-rw-rw-r--   1     1994     1994  2897280 Mar  3 18:45 wzipse40.exe


-Greg

new topic     » goto parent     » topic index » view message » categorize

3. Re: Using the 'FtpCommand' of wininet.dll

It seems like I replied in the wrong thread, so I'll post it here as well:

You can try adding {"flags","PASSIVE"} to the options list when calling InternetConnect. 
 

I was assuming that you had already changed the hostname/username/password to something other than Fabio's settings.

new topic     » goto parent     » topic index » view message » categorize

4. Re: Using the 'FtpCommand' of wininet.dll

Hi Greg Tanks for response I did a test of your code with WinXP Performed an exact copy of your code, which has "server_name", "ftp.winzip.com.

the first message is:

220 spftp/1.0.0000 Server [81.52.134.149] 331 Password required for USER, 230 Welcome to WinZip's FTP site

After this, the next message that should show the directory remains empty

I have done tests, using my server ftp.audiophoto.com.br with valid login and password, but the result in the first message is a bit bigger, but the rest is the same, always empty!

Two questions: 1-where they put the flag = "PASSIVE" 2-How you can copy and paste the message returned? It appears that you do this, easily. How is this magic? :)

Many Thanks

Sergio Gelli

new topic     » goto parent     » topic index » view message » categorize

5. Re: Using the 'FtpCommand' of wininet.dll

sergelli said...

1-where they put the flag = "PASSIVE"

The source code only seems to support "ASCII" as an option for flags.

Flags = FTP_TRANSFER_TYPE_BINARY
  Parameter = ParameterValue("flags",NULL, options) 
  if sequence(Parameter) then  
    if  equal(upper(Parameter),"ASCII") then  
      Flags = FTP_TRANSFER_TYPE_ASCII 
    end if 
 
    -- there should be something here to 
    -- check for a combination of flags 
 
  end if 
sergelli said...

2-How you can copy and paste the message returned? It appears that you do this, easily. How is this magic? :)

Just hit Ctrl+C when the message box is in focus. It will copy all the text on the message box. Then I just edit out the stuff I don't need. blink


Example:

--------------------------- 
Wininet 
--------------------------- 
220 spftp/1.0.0000 Server [204.2.225.144] 
331 Password required for USER. 
230 Welcome to WinZip's FTP site. 
 
--------------------------- 
OK    
--------------------------- 


-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: Using the 'FtpCommand' of wininet.dll

The source code only seems to support "ASCII" as an option for flags. 

You can try adding {"flags","PASSIVE"} to the options list when calling InternetConnect.

Just add it anywhere among the list of arguments:

con1 = InternetConnect({  
  ...  
  ...  
  ...  
  {"flags","PASSIVE"}  
  })  
new topic     » goto parent     » topic index » view message » categorize

7. Re: Using the 'FtpCommand' of wininet.dll

ctrl + c. .. I do not believe I forgot it!:(

The test you did was with WinXP?

new topic     » goto parent     » topic index » view message » categorize

8. Re: Using the 'FtpCommand' of wininet.dll

HI Mike I did retry using ( "flags", "PASSIVE"), but not worked

new topic     » goto parent     » topic index » view message » categorize

9. Re: Using the 'FtpCommand' of wininet.dll

Sorry emphasize this. However, is impossible to think that no one else is having this problem, While Greg has done work on your PC.

I just test the code on a third computer, and the problem continues.

I am now using a laptop Semp-Toshiba with WinXP with all programs Euphoria updated. These are the messages (5) received after run the code of Fabio Ramires, posted above by Greg.

Message 1


Wininet


ERROR_INSUFFICIENT_BUFFER


OK


message 2 Return a blank sequence

Message 3


Wininet


220-------- Welcome to Pure-FTPd [TLS] -----

220-You are user number 2 of 50 allowed.

220-Local time is now 19:16. Server port: 21.

220-This is a private system - No anonymous login

220-IPv6 connections are also welcome on this server.

220 You will be disconnected after 15 minutes of inactivity.

331 User audiopho OK. Password required

230-User audiopho has group access to: audiopho

230 OK. Current restricted directory is /


OK


message 4


Wininet


200 TYPE is now 8-bit binary

200 PORT command successful

500 ?


OK


Message 5 Return a blank sequence

Please, someone has some idea of what can be done.

Thanks in advance

Sergio

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu