Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

ASP and FTP

Question posted by: =?Utf-8?B?VmFuZXNzYQ==?= (Guest) on August 4th, 2008 09:45 PM
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
%>

Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Bob Barrows [MVP]'s Avatar
Bob Barrows [MVP]
Guest
n/a Posts
August 4th, 2008
10:05 PM
#2

Re: ASP and FTP
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:
Quote:
Originally Posted by
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.



=?Utf-8?B?c3RldmV3YQ==?='s Avatar
=?Utf-8?B?c3RldmV3YQ==?=
Guest
n/a Posts
August 13th, 2008
05:45 AM
#3

Re: ASP and FTP
Vanessa, ahve you had any success resolving this?

Adrienne Boswell's Avatar
Adrienne Boswell
Guest
n/a Posts
August 13th, 2008
01:45 PM
#4

Re: ASP and FTP
Gazing into my crystal ball I observed =?Utf-8?B?c3RldmV3YQ==?=
<stevewa@discussions.microsoft.comwriting in news:25BBE46A-4A81-4C88-
Join Bytes!:
Quote:
Originally Posted by
Vanessa, ahve you had any success resolving this?


You might want to look at [http://benmeg.com/code/asp/ftp.asp.html], FTP
without a component. I use it all the time, works great.

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share


 
Not the answer you were looking for? Post your question . . .
182,199 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors