I am passing a script to ftp.exe (using Shell) to do these actions:
1. Dir the FTP folder, redirecting the Dir output to a text file
I then import the text file into a table and examine the contents to
determine if the correct files are available)
2. Download the files if available
Using the value returned by the API's WaitForSingleObject, I can even
determine whether the FTP connection timed out (either downloading a very
large file, or the process simply hung), and using KillTask, I can kill FTP
if so.
There are two things I cannot tell, however, because they are internal to
ftp.exe.
1. Incorrect FTP server name.
2. Incorrect FTP user name and/or password
Both of these generate FTP return codes. I know I can test this manually,
but I would really like to determine this error at runtime in Access for
diagnostic purposes. As it stands, I have no way of distinguishing between an
incorrect username/password and a Dir that is legitimately empty because
there are no files on the FTP server; both result in normal termination of
FTP and an empty file list.
Is there a way to direct the output of the FTP session into a text file so
that I can examine the contents for potential FTP errors?
Dirk Goldgar - 16 Feb 2006 16:43 GMT
> I am passing a script to ftp.exe (using Shell) to do these actions:
>
[quoted text clipped - 23 lines]
> Is there a way to direct the output of the FTP session into a text
> file so that I can examine the contents for potential FTP errors?
There are class libraries available that would be more flexible.
However, to follow the approach you've been using, I believe you could
shell to the command interpreter to execute ftp.exe, and use redirection
switches to capture both the stdout and stderr output streams. Like
this, which seemed to work in a quick test:
shell "cmd /c ftp.exe -s:\temp\ftpscript.txt >\temp\ftpout.txt 2>&1"

Signature
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)