Re: [twsocket] How to handle a failed CWD with FTPClient...
Thanks for all your help, guys. Yes that makes a lot of sense. I didn't realise CWD only changed directory RELATIVE to the current directory. I've tried adding a '/' to the start of the path, but that didn't work. I've also tried a '\', but that didn't work either. Whats the easiest way of changing to the root (or rather, the HOME) directory? I did previously write a loop where it would CDUP as long as there were a certain number of '\'s left in the current directory but I scrapped that... And thanks again for all your help, this is more support than I've ever gotten for ANY product I've used Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] How to handle a failed CWD with FTPClient...
Hello, Thanks for pointing out that I can retrieve the last response from the server, I didn't realise Cwd results came just as a response and not as an event. Ok so this is what happens: HostDirName = '1\2\3\'; Cwd; // No Failure HostDirName = 'a\b\c\d\'; Cwd; // ERROR: 550 a\b\c\d\ : The system cannot find the path specified. But when I reverse the order of the directories: HostDirName = 'a\b\c\d\'; Cwd; // No Failure HostDirName = '1\2\3\'; Cwd; // ERROR: 550 1\2\3\ : The system cannot find the path specified. The path obviously exists. This error only seems to occur with directories 3 or more levels deep, and happens regardless of which server I test it on. Like I said previously the following code seems to fix this problem some of the time: if not(Cwd) then begin Quit; Connect; HostDirName := SubDir; Cwd; end; Can anyone suggest anything else I could try? Cheers Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] How to handle a failed CWD with FTPClient...
As requested I've done some more testing with this, however I'm not getting any closer. Just to reiterate, I'm trying to do a recursive download from an FTP Server to basically do a full backup. It works fine most of the time, but occasionally the Cwd command fails to change directory causing files to be downloaded in the wrong place. I was asked to check what error is bought up but unfortunately the FTPClient component doesn't generate an error via the OnError event (though it does for other things so I know I'm checking it right). There is no permissions problem - using the same username/password I can download everything via other FTP programs. The only error I get is that Cwd = false. I managed to trace the problem down to a simple test which fails every time - there seems to be a bug when changing between directories that are 3 or 4 layers deep i.e. Changing from '1/2/3/' to 'a/b/c/d' causes Cwd to fail. This happens regardless of which server I try it on and in which order I try to download the directories. Like I said in a previous email, with the following alteration the program works much better, but still fails on some directories: if not(Cwd) then begin Quit; Connect; HostDirName := SubDir; Cwd; end; Could anyone suggest a resolution or a better way to debug what's going on? Cheers Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] How to handle a failed CWD with FTPClient...
Hi, I've been having some issues with FTPClient where sometimes, on some servers, it would fail to change the working directory (thanks to whoever pointed that out btw) I've been trying to change the code to test for this and I thought I had it cracked, but its still not quite right. This is the code which seems to work best so far, but it still occasionally fails: if not(Cwd) then begin Quit; Connect; HostDirName := SubDir; Cwd; end; This is part of a function which retrieves a file listing, which is then passed onto another function which attempts to download each file. I also tried the following code, which I thought made more sense: if not(Cwd) then begin Quit; HostDirName := SubDir; if not(Connect) then exit; end; With the intention being that if after 2 attempts you still can't get a file listing, just skip it. Unfortunately this seemed to make it go completely mental so it must be doing something odd. Any suggestions please? Cheers Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] How to handle a failed CWD with FTPClient...
I'm not sure, but the code I posted up seems to work? I had an issue where, basically, a CWD command would fail when changing between directories that are 3 or 4 layers deep. For some reason the code I posted works most of the time (don't ask me why), but like I said it still occasionally fails. Just to clarify, these are directories that I KNOW exist - I'm doing a recursive download from an FTP site. How would you recommend I recover from a failed CWD command? Cheers Rick Date: Sun, 8 Oct 2006 13:03:20 +0200 From: Gunnar [EMAIL PROTECTED] Subject: Re: [twsocket] How to handle a failed CWD with FTPClient... To: ICS support mailing twsocket@elists.org Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; format=flowed; charset=iso-8859-1; reply-type=original Rick, if CWD fails, why do you expect it could work if you just try it again? -gunnar - Original Message - From: rick cusimano [EMAIL PROTECTED] To: twsocket@elists.org Sent: Sunday, October 08, 2006 12:42 PM Subject: [twsocket] How to handle a failed CWD with FTPClient... Hi, I've been having some issues with FTPClient where sometimes, on some servers, it would fail to change the working directory (thanks to whoever pointed that out btw) I've been trying to change the code to test for this and I thought I had it cracked, but its still not quite right. This is the code which seems to work best so far, but it still occasionally fails: if not(Cwd) then begin Quit; Connect; HostDirName := SubDir; Cwd; end; This is part of a function which retrieves a file listing, which is then passed onto another function which attempts to download each file. I also tried the following code, which I thought made more sense: if not(Cwd) then begin Quit; HostDirName := SubDir; if not(Connect) then exit; end; With the intention being that if after 2 attempts you still can't get a file listing, just skip it. Unfortunately this seemed to make it go completely mental so it must be doing something odd. Any suggestions please? Cheers Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
Re: [twsocket] FTP Client Bug?
Hello, Thanks DZ-Jay, you hit the nail on the head! Sorted it =o) Cheers Rick On Oct 3, 2006, at 16:53, rick cusimano wrote: Imagine you have 2 files, within the following directories: a\b\c\d\file1.txt 1\2\3\file2.txt If you try to change to one directory then to the other, you end up retrieving the same file twice, instead of 1 file from each directory. !SNIP Please post some code, or at least pseudo-code explaining the algorithm you are using. Are you checking the return code of CWD when you change directories? One thing to note is that if the CWD fails, the directory won't be changed, so you must make sure to check for errors after changing working directories. -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
[twsocket] FTP Client Bug?
Hellol, I'm having problems with the FTP Client component which I've managed to narrow down to one simple test. There seems to be a bug when retrieving directory listings/changing directories. In particular, when changing between directories which are 3 or more layers deep. I've tried the following test on 2 different FTP servers, and it fails on both: Imagine you have 2 files, within the following directories: a\b\c\d\file1.txt 1\2\3\file2.txt If you try to change to one directory then to the other, you end up retrieving the same file twice, instead of 1 file from each directory. I have no problems when the directory path is smaller, in fact, I've been using the code I've written for about 6 months now and I've only just noticed the bug. If anyone could shed any light on this, or show me an example which works, I would be most grateful. Thanks and Kind Regards Rick -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be