Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirming FTP Completion

Status
Not open for further replies.

MikeC14081972

Programmer
May 31, 2006
137
0
0
GB
Hi,

I'm using Access 2007 and have a module that creates a ftp script at runtime and then executes a .bat file passing in the name of the script to run.

The .bat file looks like
Code:
ftp -s:{script file} {server name}

The ftp script looks like
Code:
{Username}
{Password}
cd {destination on server}
put {filename to send}
bye

The above works as expected and sends the file via ftp to the serverwhen I run the shell command from with Access and the user is shown the completion message as my VBA code will halt whilst the SHELL process is still running then continue on comletion.

However if I change the password to an invalid one (as part of a test) the ftp script will continue to run through till the end and then quit. Leading the VBA code to assume it has completed correctly.

Is there anyway to either stop the script file completing if there is an issue or for Access to check the script ran correctly?

Thanks in Advance.

Mike
 
Hi

Why not just check if file exists after shelled program ran?
See below.

Regards

Kevin

An Allen Brown routine to check:

Code:
Function FileExists(ByVal strFile As String, Optional bFindFolders As Boolean) As Boolean
    'Purpose:   Return True if the file exists, even if it is hidden.
    'Arguments: strFile: File name to look for. Current directory searched if no path included.
    '           bFindFolders. If strFile is a folder, FileExists() returns False unless this argument is True.
    'Note:      Does not look inside subdirectories for the file.
    'Author:    Allen Browne. [URL unfurl="true"]http://allenbrowne.com[/URL] June, 2006.
    Dim lngAttributes As Long

    'Include read-only files, hidden files, system files.
    lngAttributes = (vbReadOnly Or vbHidden Or vbSystem)

    If bFindFolders Then
        lngAttributes = (lngAttributes Or vbDirectory) 'Include folders as well.
    Else
        'Strip any trailing slash, so Dir does not look inside the folder.
        Do While Right$(strFile, 1) = "\"
            strFile = Left$(strFile, Len(strFile) - 1)
        Loop
    End If

    'If Dir() returns something, the file exists.
    On Error Resume Next
    FileExists = (Len(Dir(strFile, lngAttributes)) > 0)
End Function
 
I could use that except that the file now resides on an Unix server and I only have the built in windows FTP client to use and there is no command to check a file exists.

I could use get and place it in another location and then check that location but this would add additional overheads to the running of the code and wouldn't be very practical.

What I really need is the ability to trap errors that may occur in the console at runtime.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top