Help with FTP

T

Tim

I'm shelling FTP from within VBA to retrieve a file from one of our servers.
The process is running correctly from my work directory, but when I move it
to a public directory - nothing else changes except for the location of the
..mdb - it appears that the FTP process is not finding the desired file
(which does exist and which is retrieved when I run the exact same .mdb [no
changes] from the work directory).

Two questions:

1. Is there something unique about the"spawned" process that inherits
rights / priveleges from the directory from which the .mdb was run?

2. Is there a means of logging the results of the FTP when it is shelled?
Meaning... if, at a command line, I type:

ftp -s:somefile >someLog.txt

The results of the FTP process are written to someLog.txt. When I attempt
to use that same syntax as the shelled command, ftp runs, but no log file is
created.

Oh... the PID returned by the shell command is non-zero, so it appears as if
the FTP command is executing w/o a problem. It's just not returning the
file (a GET).

Any observations on prior experience, or hypothesis on what might be
occurring, would be most welcome.

TIA
 
D

Dan Artuso

Hi,
Yes, you can redirect the output to a text file using shell.
If it works from the command line, it'll work with Shell.

Can't offer any more help without seeing some code.
 
T

Tim

Yes, you can redirect the output to a text file using shell.
If it works from the command line, it'll work with Shell.

Can't offer any more help without seeing some code.

Here's a snippit containing the code being used to create the script file and the shell.

Set fileDef = fs.CreateTextFile(strPath & _
strFTPScriptFile, True)

fileDef.writeLine ("open " & strImportServer)
fileDef.writeLine (strImportUserID)
fileDef.writeLine (HideIt(strImportPassword))
fileDef.writeLine ("cd " & strImportDirectory)
' the following will not work if there is a time stamp in the file name
fileDef.writeLine ("get " & strFileName & " " & strPath & strFileName)
fileDef.writeLine ("quit")
fileDef.Close

' FTP the file
ChDir strPath
strCommand = "FTP.exe -s:" & strFTPScriptFile & " >" & strFTPLogFileName
lngPid = Shell(strCommand)

Here's the resulting FTP command created by the above:

FTP.exe -s:tmpFTP.txt >tmpFTPCommandResults.log

It does not create the log file when run from shell. If, however, I capture the command in debug, open a DOS window, paste the command and execute it, the log file IS created.

So... I'm baffled as to why the log file is being generated. The parent process from which this code was extracted is able to create and delete the script file (tmpFTP.txt) in the same directory, so... presumably there shouldn't be an permissions problem when trynig to open/create "tmpFTPCommandResults.log".

And... without the results from that log file, there isn't much chance we'll be able to figure out when the FTP is failing when executed from a different directory (that supposedly has the exact same permissions as the test directory).

BTW, many thanks for taking the time to review this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top