Write file from asp page.

M

MichaelK

I need to write a log file on server side.
I'm using the code below. By some reason it just hanging on and not doing
anything.
Just the progress bar is moving very very slow and maximum gets to the
middle.
Tryed it on two different server, same result.
I have feeling I used to run this before with Server.MapPath and without,
and it worked.
But not now.

Can somebody tell what's wrong with it?
Thanks,
Michael

Here is the code:

<%
sub WriteToFile(FileName, Contents, Append)
on error resume next
Dim oFs, oTextFile, iMode
if Append = true then
iMode = 8
else
iMode = 2
end if
set oFs = server.createobject("Scripting.FileSystemObject")
set oTextFile = oFs.OpenTextFile(FileName, iMode, True)
oTextFile.Write Contents
oTextFile.Close
set oTextFile = nothing
set oFS = nothing

end sub

WriteToFile "zzz.txt", "XXXXXXXXXXXXXXXXX", true

response.write "Recorded"
%>
 
M

McKirahan

MichaelK said:
I need to write a log file on server side.
I'm using the code below. By some reason it just hanging on and not doing
anything.
Just the progress bar is moving very very slow and maximum gets to the
middle.
Tryed it on two different server, same result.
I have feeling I used to run this before with Server.MapPath and without,
and it worked.
But not now.

Can somebody tell what's wrong with it?

Try changing

set oTextFile = oFs.OpenTextFile(FileName, iMode, True)

to

set oTextFile = oFs.OpenTextFile(Server.MapPath(FileName), iMode, True)
 
D

Dan

If you have Antivirus installed on your server, make sure you set the proper
option.
Antivirus can prevent fso script to work too.
 
M

McKirahan

MichaelK said:
I need to write a log file on server side.
I'm using the code below. By some reason it just hanging on and not doing
anything.
Just the progress bar is moving very very slow and maximum gets to the
middle.
Tryed it on two different server, same result.
I have feeling I used to run this before with Server.MapPath and without,
and it worked.
But not now.

Can somebody tell what's wrong with it?

Remove or comment out the line:
on error resume next
and see what error message you get.
 
M

MichaelK

Thanks guys.
Yes I had the script blocking enabled in Norton Antivirus.
And on one server it works fine now with both MapPath and without.
On another still hanging on.
Commented on error.
Got "The maximum amount of time for a script to execute was exceeded",
but it's not a reason (90 sec would be more then enough).

May be something in IIS configuration not letting me?
I enabled Write option on the Home Directory tab in Website properties,
didn't help. Besides the working one has this disabled.

Any other ideas?

Regards,
Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top