Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FTP in ASP

42 views
Skip to first unread message

Michael

unread,
Oct 18, 2000, 3:00:00 AM10/18/00
to
When a user buys something from a site a file is created with the items he
bought and a purchase order number. Is there a server object or method that
I can use to ftp this file to the company that fills these order?

Dominic Marks

unread,
Oct 18, 2000, 3:00:00 AM10/18/00
to
Recently a very large number of people have wanted to use FTP in their
scripts. Here is how with a sample.

Firstly you need to get 2 components (both written by Jeff Mastry). They are
FTP.WSC and SHELL.WSC. Both of which are probably only a maximum of 10 kb in
total (probably less). Then you will need to have them successfully
registered on that machine (like any other activex control). You can find
and download these from http://cwashington.netreach.net/.

Once you have these both complete you can write script like the following.

>
Dim oFTP
Set oFTP = CreateObject ("FTP.WSC")
With oFTP
.Host = ftp.myisp.net
.Username = "me" ' default it anonymous
.Password = "pwd" ' default is also anon (e-mail address)
.FtpExecute "put x:\path_1\path_2\file.ext"
End With
Set oFTP = Nothing
<

AFAIK this should work inside ASP pages with no problems.

Dominic

"Michael" <mma...@ntwo.com> wrote in message
news:OrSNr2U...@cppssbbsa02.microsoft.com...

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

Thank you Mr. Marks, I visited the site and did not see anything on the page
but I did send him feedback requesting it. I hope this works out.

Mike

"Dominic Marks" <dominic_marks*@hotmail.com> wrote in message
news:e68cZUVOAHA.244@cppssbbsa04...

Dominic Marks

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

You should search for it.

Dominic (call me Dominic, Mr. Marks is scary :)

"Michael" <mma...@ntwo.com> wrote in message

news:eA8GYac...@cppssbbsa02.microsoft.com...

Al Dunbar

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

"Dominic Marks" <dominic_marks*@hotmail.com> wrote in message
news:#uDHHKfOAHA.252@cppssbbsa05...

>
> You should search for it.
>
> Dominic (call me Dominic, Mr. Marks is scary :)

Carl or Groucho?

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

I have found a couple of different ways of executing the FTP. One is with
wsh. After finally convincing our Server Administrator that two of our files
were not registered he registered them. and another is a program through
ServerObjects.com The program that came from ServerObjects fails to
transfer the file and this program lets me know that. At least something is
happening though. And with wsh the file does not kick up an error but still
the file is not ftped. ServerObjects offeres no tech support for their
program and the documentation sucks.
Thanks again Dominic.

Mike
"Dominic Marks" <dominic_marks*@hotmail.com> wrote in message

news:#uDHHKfOAHA.252@cppssbbsa05...
> You should search for it.
>
> Dominic (call me Dominic, Mr. Marks is scary :)
>

Dominic Marks

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
As yet undecided :)

"Al Dunbar" <Al_D...@HoTMaiL.com> wrote in message
news:suud01a...@corp.supernews.com...


>
> "Dominic Marks" <dominic_marks*@hotmail.com> wrote in message
> news:#uDHHKfOAHA.252@cppssbbsa05...
> >
> > You should search for it.
> >
> > Dominic (call me Dominic, Mr. Marks is scary :)
>

> Carl or Groucho?

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

Dominic - Any thoughts on why the file may not get to the ftp destination?


"Dominic Marks" <dominic_marks*@hotmail.com> wrote in message

news:#$qllqfO...@cppssbbsa02.microsoft.com...

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

I know that the ftp destination is written in correctly

Dominic Marks

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
I wouldnt know without seeing what kind of code your using?

Are you using the components I reccomended or some others?

Dominic

"Michael" <mma...@ntwo.com> wrote in message

news:eZpu2yf...@cppssbbsa02.microsoft.com...


> Dominic - Any thoughts on why the file may not get to the ftp destination?
>
>

> "Dominic Marks" <dominic_marks*@hotmail.com> wrote in message

> news:#$qllqfO...@cppssbbsa02.microsoft.com...
> > As yet undecided :)
> >

Al Dunbar

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
"written in correctly" or "written incorrectly"?

"Michael" <mma...@ntwo.com> wrote in message

news:uSDQPzf...@cppssbbsa02.microsoft.com...


>
> I know that the ftp destination is written in correctly
>

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

It is written correctly

"Al Dunbar" <Al_D...@HoTMaiL.com> wrote in message
news:suuia3n...@corp.supernews.com...

Michael

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to

<%@ Language = "VBScript"%>

<%
tempfile = Now()
tempfile = replace (tempfile, "/", "")
tempfile = replace (tempfile, ":", "")
tempfile = replace (tempfile, " ", "")
response.write tempfile
filename = tempfile & ".log"
set FSO = Server.CreateObject("Scripting.FileSystemObject")
set myFile = FSO.CreateTextFile(Server.MapPath(filename), 8, true)

MyFile.WriteLine "This is gonna work"
myFile.Close

set myFile2 = FSO.CreateTextFile(Server.MapPath("test.ftp"), 8, true)
myFile2.WriteLine "open ftp.somewhere.com" & chr(13)
myfile2.WriteLine "user UserName Password" & chr(13)
myfile2.WriteLine "put ../FTP/" & filename & "ExpoShop/" & filename
myfile2.WriteLine "quit"

Set WshShell = Server.CreateObject("WScript.Shell")
runStr="%comspec% /c ftp -n -v -d -s:test.ftp>logfile.txt"
rc=WshShell.Run (runStr, 0, TRUE)
%>


<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>

<body>
<%
'FTP_TRANSFER_TYPE_ASCII = 1
'FTP_TRANSFER_TYPE_BINARY = 2
'Set FtpConn = Server.CreateObject("AspInet.FTP")
'if FtpConn.FTPPutFile("ftp.somewhere.com", "UserName", "Password",
"test.txt", "test.txt", FTP_TRANSFER_TYPE_BINARY) then
' Response.Write "<p>FTP upload Success...<br>"
'else
' Response.Write "<p>FTP upload Failed...<br>"
' Response.Write "Last Eror was: " & FtpConn.LastError
'end if


%>
</body>

</html>
For obvious reasons some items have been changed. The remmed out code
produces the result

FTP upload Failed...
Last Error was: 0

The unremmed code only produces the filename with the response.write

Tom Lavedas

unread,
Oct 19, 2000, 3:00:00 AM10/19/00
to
See comment below.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Michael wrote:
>
> <%@ Language = "VBScript"%>
>
> <%
> tempfile = Now()
> tempfile = replace (tempfile, "/", "")
> tempfile = replace (tempfile, ":", "")
> tempfile = replace (tempfile, " ", "")
> response.write tempfile
> filename = tempfile & ".log"
> set FSO = Server.CreateObject("Scripting.FileSystemObject")
> set myFile = FSO.CreateTextFile(Server.MapPath(filename), 8, true)
>
> MyFile.WriteLine "This is gonna work"
> myFile.Close
>
> set myFile2 = FSO.CreateTextFile(Server.MapPath("test.ftp"), 8, true)
> myFile2.WriteLine "open ftp.somewhere.com" & chr(13)

> myfile2.WriteLine "user UserName Password" & chr(13)

In my experience, the inclusion of the Password on the same line as the
UserName does not work. I believe it must be on a separate line in the
script, i.e. ...

myfile2.WriteLine "user UserName" & vbNewline & "Password"

Also, I'd remove all of those Chr(13)'s since the Writeline method
provides them anyway.


> myfile2.WriteLine "put ../FTP/" & filename & "ExpoShop/" & filename

You are also missing a space between the first 'filename and the string
that names the target location in the preceding line, i.e. ...

myfile2.WriteLine "put ../FTP/" & filename & " ExpoShop/" & filename

This will result in the 'put' having only one argument instead of the
desired two.

0 new messages