all groups > inetserver asp components > march 2004 >
You're in the

inetserver asp components

group:

inet, ftp, asp and hardship


inet, ftp, asp and hardship arvaco
3/11/2004 11:42:42 AM
inetserver asp components:
I need to send an updated file to a remote server via ftp whenever
someone loads an asp page. I can do this with VB but when I tried the code
in asp I get one of those 'cannot coerce type' errors. Here's what I have so
far:

Rfile = "traffic.htm"
Lfile = "C:\Inetpub\wwwroot\Traffic\traffic.htm"

cmd = "PUT " & Lfile & " " & Rfile

set inet = createobject("inetctls.inet")
inet.requesttimeout=60
inet.protocol=icFTP
Inet.URL = "ftp://TheURL/"
Inet.UserName = "myname"
Inet.Password = "mypassword"
inet.execute , cmd

The code is oh so close to the VB code except I used inet.execute,
"DIR" to log on in the VB code. If I try the same routine in the asp code
it never stops executing the command.
I can do what I need done by shelling a VB program to send the file but
that just seems like the lazy way around something simple but I may have no
choice.
Can I actually do this in asp or is there some kind of security setting
to prevent this? Any help would be appreciated.

Re: inet, ftp, asp and hardship arvaco
3/11/2004 4:58:01 PM

[quoted text, click to view]

Hi McKirahan. I tried inetctls.inet and inetctls.inet.1 they both work for
other things and MSINET.OCX is registered. I found some code that had a
'loop while inet.stillexecuting', and tried that and it timed out all the
time. Very strange that it works fine from a VB project but not from an asp
page. I think I'll go with the shelling the VB app (or try wrapping the code
in a dll) until I get it worked out. It seems a little dirty but I'm not
building rocket ships. What bugs me is I did try it in a VBS file and I also
got the same error, so I don't think it''s an asp problem...

Re: inet, ftp, asp and hardship McKirahan
3/11/2004 8:56:15 PM
[quoted text, click to view]


Probably not much help but ...

1) Try Server.CreateObject("InetCtls.Inet")
or
Try Server.CreateObject("InetCtls.Inet.1")

2) Is "MSINET.OCX" available and registered on the Web server?


I put your code in a VBS file and got the same error:

Option Explicit
'*
Const cVBS = "uploader.vbs"
Const cDIR = "c:\inetpub\wwwroot\traffic\"
Const cFIL = "traffic.htm"
Const cURL = "ftp://{domain}/{path}/"
Const cUSR = "{username}"
Const cPWD = "{password}"
'*
Dim strCMD
' strCMD = "put " & cDIR & cFIL & " " & cFIL
strCMD = "dir"
Dim strPWD
strPWD = cPWD
If strPWD = "" Then strPWD = InputBox("Password?","")
If strPWD = "" Then WScript.Quit
'*
WScript.Echo strCMD
'*
Dim objNET
Set objNET = CreateObject("InetCtls.Inet.1") '= MSInet.ocx
objNET.RequestTimeout = 60
'objNET.AccessType = 0 '= icUseDefault
objNET.Protocol = 2 '= icFTP
'objNET.RemotePort = 80
objNET.URL = cURL
objNET.UserName = cUSR
objNET.Password = strPWD
objNET.Execute, strCMD
'*
Do
' WScript.Echo "." ': uncomment if running via CScript
WScript.Sleep 100
Loop While objNET.StillExecuting
'*
objNET.Execute, "Close"
Set objNET = Nothing
'*
WScript.Echo cVBS & " ended."

I did a Google search on "Cannot coerce type" but found no answer.

AddThis Social Bookmark Button