Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > ASP and FTP

Reply
Thread Tools

ASP and FTP

 
 
Vanessa
Guest
Posts: n/a
 
      08-04-2008
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
%>

 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      08-04-2008
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.


 
Reply With Quote
 
 
 
 
stevewa
Guest
Posts: n/a
 
      08-13-2008
Vanessa, ahve you had any success resolving this?
 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      08-13-2008
Gazing into my crystal ball I observed =?Utf-8?B?c3RldmV3YQ==?=
<> writing in news:25BBE46A-4A81-4C88-
BA1F-:

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
64 bit FTP software and why did Microsoft leave out a FTP softwareout of all versions of win 7? inventor1984 Windows 64bit 4 12-21-2009 04:21 PM
Pix firewalls and FTP - "ftp", or "ftpdata" thefunnel@aol.com Cisco 1 09-13-2007 04:01 PM
Re: ftplib question - ftp.dir() returns something and ftp.nlst()does not Nico Grubert Python 0 11-25-2005 10:09 AM
ftplib question - ftp.dir() returns something and ftp.nlst() does not Nico Grubert Python 0 11-24-2005 02:00 PM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM



Advertisments