This is not a job to do via ASP. Why do you think ASP needs to be
involved in this? This process you have described does not involve
generating html to be served to a client.
This is a task that needs to be scheduled on your server's operating
system. See:
http://www.aspfaq.com/show.asp?id=2143
Vanessa wrote:
> Hi Everyone,
>
> I have a new project for which we want to exchange files with our
> remote support center via FTP without human intervention.
>
> Our company is using Microsoft Navision while our remote support
> center is using their own system (for which I don't know what it is).
>
> My original idea is having an ASP programming script, which will be
> scheduled to run daily on the server, to perform following:
>
> 1) Check Navision to see if any new orders are created for that
> particular location on that day. If yes, the script will generate
> the CSV file and upload the file into FTP automatically.
>
> 2) It will also check if any new files are uploaded by our support
> center on that day. If yes, it will download the file from the FTP
> and 'import' data back to Navision.
>
> However, I've tested out the FTP function with ASP programming, but
> it gave me access denied permission as the 'website account' doesn't
> have enough access level to execute the FTP command lines.
>
> I have researched online and experts suggested that we will need to
> configure IIS to use an impersonation account with admin rights on
> our site but that might give the security risks involved. I don't
> think we want to set the 'website account' with Admin rights.
>
> Please advise if any other ways I can have this problem resolved, or
> any other solutions can be achieved the same goal will be greatly
> appreciated.
>
> THANK YOU!!
>
> Here is the coding:
>
> <%
> Dim strHost, strUser, strPass, strMode, LocalDir, RemoteDir
> Dim Output, ReturnCode, strScript
> Const COMMAND_FTP = "ftp.exe -i -s:"
>
> strHost = "ftp://###.###.###.###/"
> strUser = "username"
> strPass = "password"
> strMode = "ascii" '=== "ascii" / "binary"
> LocalDir = "\FTPTEST"
> RemoteDir = "/images/"
>
> Function FTP( strCMD )
> Dim objFSO, strFile, objTempFldr, objFile, objRegExp
> Dim objShell, WSX, ReturnCode, Output, strLog, strErrorLog
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
>
> strFile = Server.MapPath("FTPTEST/temptemp.ftp")
> response.write strFile & "<BR>"
>
> if not objFSO.FileExists( strFile ) then objFSO.CreateTextFile(
> strFile ) Set objFile = objFSO.OpenTextFile( strFile, 2, True )
>
> objFile.WriteLine( strUser )
> objFile.WriteLine( strPass )
> If LocalDir <> "" Then objFile.WriteLine( "lcd " & LocalDir )
> If RemoteDir <> "" Then objFile.WriteLine( "cd " & RemoteDir )
> objFile.WriteLine( strMode )
>
> objFile.WriteLine( strCMD )
> objFile.WriteLine( "bye" )
> objFile.Close()
>
> Set objShell = Server.CreateObject("WScript.Shell")
>
> set WSX = objShell.Exec( COMMAND_FTP & strFile & " " & strHost ) '<--
> ERROR ERROR!!! WshShell.Exec error '80070005' Access is denied.
> set ReturnCode = WSX.StdErr
> set Output = WSX.stdOut
> strErrorLog = Server.MapPath("FTPTEST") & "ftpErrors.txt"
> strLog = Server.MapPath("FTPTEST") & "ftpLog.txt"
>
> Set objFile = objFSO.OpenTextFile( strErrorLog, 2, True )
> objFile.Write( ReturnCode.ReadAll() )
> objFile.Close()
>
> Set objFile = objFSO.OpenTextFile( strLog, 2, True )
> objFile.Write( Output.ReadAll() )
> objFile.Close()
> set objFSO = nothing
> set objFile = nothing
>
> objFSO.DeleteFile strFile, True
> set objFSO = nothing
>
> Set objRegExp = New RegExp
> objRegExp.IgnoreCase = True
>
> objRegExp.Pattern = "not connected|invalid command|error"
>
> If (objRegExp.Test( Output.ReadAll ) = True ) or (objRegExp.Test(
> ReturnCode.ReadAll ) ) Then 'on one line
> FTP = False
> Else
> FTP = True
> End If
> Set objRegExp = nothing
> End Function
>
> strCommands = "GET ac.gif"
>
> 'calling the function =============================================
> SUCCESSTEST = FTP( strCommands )
> response.Write SUCCESSTEST
> %>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.