Write file from asp page.

Discussion in 'ASP General' started by MichaelK, May 11, 2006.

  1. MichaelK

    MichaelK Guest

    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"
    %>
     
    MichaelK, May 11, 2006
    #1
    1. Advertising

  2. MichaelK

    McKirahan Guest

    "MichaelK" <> wrote in message
    news:#psFJ$...
    > 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)
     
    McKirahan, May 11, 2006
    #2
    1. Advertising

  3. MichaelK

    Dan Guest

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

    "MichaelK" <> wrote in message
    news:%23psFJ$...
    >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"
    > %>
    >
    >
    >
    >
     
    Dan, May 11, 2006
    #3
  4. MichaelK

    McKirahan Guest

    "MichaelK" <> wrote in message
    news:#psFJ$...
    > 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.
     
    McKirahan, May 11, 2006
    #4
  5. 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.
     
    Bob Barrows [MVP], May 11, 2006
    #5
  6. MichaelK

    MichaelK Guest

    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

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    > 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.
    >
    >
     
    MichaelK, May 11, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RGF2ZSBT?=

    how to write asp.net 2 code for file send page as email

    =?Utf-8?B?RGF2ZSBT?=, Mar 19, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    4,376
    =?Utf-8?B?RGF2ZSBT?=
    Mar 19, 2006
  2. Chuck
    Replies:
    0
    Views:
    283
    Chuck
    Jul 5, 2003
  3. fniles
    Replies:
    6
    Views:
    684
    Karl E. Peterson
    Apr 27, 2009
  4. Iulian Ilea
    Replies:
    1
    Views:
    347
    pcx99
    Dec 21, 2006
  5. Tim Chase
    Replies:
    0
    Views:
    108
    Tim Chase
    Dec 16, 2013
Loading...

Share This Page