1. FTP Routines - help, please

I have been struggling with FTP access. let me explain. We have an FTP server which requires username and password. I can access this using routines I have got in libraries from contribs. I can read and write files. This is all very nice. What I can't do is perform a "dir" function. I have used the ftp command LIST, which returns a dir, but when I then change the directory with FtpSetCurrentDirectory, the LIST command no longer works. I have tried to get the FtpFindFirstFile and InternetFindNextFile commands to work but I am having great problems.

Since FTP is a well established protocol and since you Euphoria guys are mostly well-versed in internet access, can you help me? We don't have a URL for our FTP server, and I am not sure this will help. I have, of course, a fixed IPA, which accesses it fine. If I simply had an FTP server with a URL I could tell Windows (yes, WinXP) to alias it, but I don't want the general public to be able to access it.

I have probably missed something obvious; this is an area I have not worked with before. And I need help. the libraries I have been using are by Fabio Ramirez and by Daniel Berstein; these have different good points but neither really allows me to dir a folder so I can display the folder contents to my user. Oh, I still use Eu3 and will do until Eu4 is solid and I have got used to it.

So - any offers of help, Gentlemen?

new topic     » topic index » view message » categorize

2. Re: FTP Routines - help, please

Have you looked at using wxEuphoria's FTP routines? They're fairly complete and include a simple ftp_dir() routine.

wxEuphoria said...


ftp_dir ( atom ftp, sequence wildcard )
Category: wxFTP

The GetList function is quite low-level. It returns the list of the files in the current directory. The list can be filtered using the wildcard string. If wildcard is empty (default), it will return all files in directory.

The form of the list can change from one peer system to another. For example, for a UNIX peer system, it will look like this:

-r--r--r--     1 guilhem  lavaux      12738 Jan 16 20:17 cmndata.cpp 
-r--r--r--     1 guilhem  lavaux      10866 Jan 24 16:41 config.cpp 
-rw-rw-rw-     1 guilhem  lavaux      29967 Dec 21 19:17 cwlex_yy.c 
-rw-rw-rw-     1 guilhem  lavaux      14342 Jan 22 19:51 cwy_tab.c 
-r--r--r--     1 guilhem  lavaux      13890 Jan 29 19:18 date.cpp 
-r--r--r--     1 guilhem  lavaux       3989 Feb  8 19:18 datstrm.cpp 


But on Windows system, it will look like this:

winamp~1 exe  520196 02-25-1999  19:28  winamp204.exe 
      1 file(s)           520 196 bytes 


-Greg

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

3. Re: FTP Routines - help, please

ghaberek said...

Have you looked at using wxEuphoria's FTP routines? They're fairly complete and include a simple ftp_dir() routine.


-Greg

Thanks, Greg. I knew there was something good somewhere. I have downloaded WxEuphoria and I am now trying to incorporate the code into my program. If I have queries I shall come back to you but I suspect it will work out OK. Maybe I should take up problems with Matt, though? Ah, but there won't be any, will there?!?

Andy

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

4. Re: FTP Routines - help, please

I don't suppose these ftp routines can exist apart from wxEuphoria, can they?

I tried to run my code with both wxeud.e and win32lib.ew included and come up with a selection of namespace problems. Trouble is, they are often knee-deep in nested includes in win32lib and trying to add namespace qualifiers to everything is going to take forever minus epsilon.

Any more ideas? I am getting ulcers doing this...

Andy

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

5. Re: FTP Routines - help, please

AndyDrummond said...

I don't suppose these ftp routines can exist apart from wxEuphoria, can they?

I tried to run my code with both wxeud.e and win32lib.ew included and come up with a selection of namespace problems. Trouble is, they are often knee-deep in nested includes in win32lib and trying to add namespace qualifiers to everything is going to take forever minus epsilon.

Any more ideas? I am getting ulcers doing this...

Andy

As wxeud.e is all in one file (which is generated by wrap.exu IIUc), it seems easier to just rename everything in that file.

On Linux, the following commands would be:

sed -i "s/function /function wxeud_/g" wxeud.e sed -i "s/procedure /procedure wxeud_/g" wxeud.e

and there are Windows versions of sed on the net.

(fixing global variables or global constants would be more troublesome, though).

Alternatively, simply copy out the parts of wxeud.e that define the ftp routines into a wxftp.e and include that?

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

6. Re: FTP Routines - help, please

AndyDrummond said...

I don't suppose these ftp routines can exist apart from wxEuphoria, can they?

I tried to run my code with both wxeud.e and win32lib.ew included and come up with a selection of namespace problems. Trouble is, they are often knee-deep in nested includes in win32lib and trying to add namespace qualifiers to everything is going to take forever minus epsilon.

Any more ideas? I am getting ulcers doing this...

Basically, the wxeuphoria routines are compiled C in the DLL. As Greg suggested, the easiest thing might be to cut it down to a very simple wrapper, or at least change the scopes of everything you don't need.

I'm not sure what the minimal wrapper might look like. You'll probably need at least the init stuff, but I think that's all local, so it probably shouldn't be causing namespace issues for you.

Matt

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

7. Re: FTP Routines - help, please

Matt, Greg,

Thanks - I have managed to get around the problem even if it is a temporary fix. I now close the ftp connection after any access, then next time I want to read a directory, read a file or write a file, I close the connection and re-open it. I'm not sure if I should have said session rather than connection, but in any case it seems to work.

I will have to sort this out properly sometime so I will pay attention to what you have said, but for now, for this job, for this ulcer, this will do.

I never did understand networking - why is it so horrendously complicated? It seems that you now have the link between computers as a more complex task than the task for which you want the link. Something wrong there...

Anyway, for now, OK, for the future, I need to learn a lot Thanks again.

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

8. Re: FTP Routines - help, please

AndyDrummond said...

Thanks, Greg. I knew there was something good somewhere. I have downloaded WxEuphoria and I am now trying to incorporate the code into my program. If I have queries I shall come back to you but I suspect it will work out OK. Maybe I should take up problems with Matt, though? Ah, but there won't be any, will there?!?

Post your questions here and we will all do our best to answer them.

AndyDrummond said...

I tried to run my code with both wxeud.e and win32lib.ew included and come up with a selection of namespace problems. Trouble is, they are often knee-deep in nested includes in win32lib and trying to add namespace qualifiers to everything is going to take forever minus epsilon.

I suggest moving your project entirely to wxEuphoria. That way you have only one library to deal with instead of two or four or however many. Your program will also be almost inherently cross-platform, which leaves that door open, even if you don't plan on using it right now.

AndyDrummond said...

Any more ideas? I am getting ulcers doing this...

Don't stress out. Programming should be enjoyable. Just take your time, ask lots of questions, and try to figure things out one at a time rather than all at once.

-Greg

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

9. Re: FTP Routines - help, please

ghaberek said...

Post your questions here and we will all do our best to answer them.

I suggest moving your project entirely to wxEuphoria. That way you have only one library to deal with instead of two or four or however many. Your program will also be almost inherently cross-platform, which leaves that door open, even if you don't plan on using it right now.

Don't stress out. Programming should be enjoyable. Just take your time, ask lots of questions, and try to figure things out one at a time rather than all at once.

-Greg

Greg,

Yes, programming should be fun. Well, it IS fun, but 95% of my coding is not for PC, and of that I have managed to avoid network coding till now. Now I have a large database program which programs an external module via USB, and suddenly it has become desirable for our config data to be held on our server here. That has FTP access for remote access to files etc, using FileZilla client, which is fine. But I want to give configurators access to get and put config files without allowing any other access. All quite straigtforward providing I have a library of ftp routines to give remote access. But despite ftp being ages old, there doesn't seem to be a coherent set of routines.

I am using Wininet.dll functions, but they don't include such unusual and esoteric functions as "dir", or so it seems. So I have to use the FTP command LIST, which works. What I don't understand is that I seem to have to open access with my IP address, username and password, do one thing, and then close the handle. I then repeat the performance for the next task. This strikes me as being besically wrong, of course. it works, but it is slow, and probably flakey in customer use.

I could rewrite the whole thing in wxEuphoria, given about a year to get to grips with it having spent years and years with Win32Lib and Judith's wonderful IDE, so that is not on. I could write a stand-alone ftp program in wxEu, to find, open and return a file, and to put it, but even then the same problem applies.

I started on DOS programming at DOS 3. Then DOS 5, 6, Win3, Win95, Win98, and now on WinXP, changing from C to Euphoria about 8 years ago. So my memory banks are about stuffed with techniques and editors and compilers and IDEs and whatnot. And PC coding is not even my main job So thanks for your help and encouragement. I am interested to see where this all goes now. Will Eu4 have a set of FTP routines built in? Will there be a library of FTP routines? I expect so, but I don't even have time to pore over the dox to see....... tempus fugit.

Andy

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

10. Re: FTP Routines - help, please

Just in case any other users read this and wondered either what I was on about or what the answer is, I have found it.

After an FTP data transfer of a directory listing, or a file either way, you must close the handle with, in this case, InternetCloseHandle(hftp) Then it all runs as I expected it to run. OK, I know I should have known that, but it just got mentioned in one little place. I did that and it all ran hunky-dory.

Andy

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

Search



Quick Links

User menu

Not signed in.

Misc Menu