Home All Groups Group Topic Archive Search About

Write file from asp page.



Author
11 May 2006 12:13 AM
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"
%>

Author
11 May 2006 12:27 AM
McKirahan
Show quote
"MichaelK" <micha***@gomobile.com> wrote in message
news:#psFJ$IdGHA.3900@TK2MSFTNGP05.phx.gbl...
> 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)
Author
11 May 2006 3:27 AM
Dan
If you have Antivirus installed on your server, make sure you set the proper
option.
Antivirus can prevent fso script to work too.

Show quote
"MichaelK" <micha***@gomobile.com> wrote in message
news:%23psFJ$IdGHA.3900@TK2MSFTNGP05.phx.gbl...
>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"
> %>
>
>
>
>
Author
11 May 2006 5:35 AM
McKirahan
"MichaelK" <micha***@gomobile.com> wrote in message
news:#psFJ$IdGHA.3900@TK2MSFTNGP05.phx.gbl...
> 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.
Author
11 May 2006 11:28 AM
Bob Barrows [MVP]
MichaelK wrote:
> 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.

http://www.aspfaq.com/show.asp?id=2180

--
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.
Author
11 May 2006 4:54 PM
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

Show quote
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:O6BYD4OdGHA.4576@TK2MSFTNGP05.phx.gbl...
> MichaelK wrote:
>> 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.
>
> http://www.aspfaq.com/show.asp?id=2180
>
> --
> 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.
>
>

AddThis Social Bookmark Button