W2K/IIS/ASP : Read / Write impossible with Scripting.FileSystemObject despite r/w rights setup

FileExists works correctly,
but read, write and create ops make the page hang, without error message.

have already checked the rights, following archived ExEx posts, but without effect.
Have checked with firewall / AV disabled, without effect.

The script works fine on my dev environment (XP Pro/IIS).
Problem is on target machine (W2K,IIS).

sample code :
<%
Dim FSO, fichier,ligne,strpath
strPath = Server.MapPath("testcmbp.txt")
Set FSO = server.CreateObject("Scripting.FileSystemObject")

Set fichier = FSO.Opentextfile(strpath,2,true)' 2:w  8:a
fichier.writeline now()
fichier.WriteLine "xavier"
fichier.writeline String(50,"-")
fichier.Close

set fichier=FSO.opentextfile(strpath,1,true)'1 : read
do until fichier.atendofstream
ligne=fichier.readline()
response.write(ligne&"<br>")
loop
fichier.close

Set fichier=nothing
set fso=nothing

%>      

Any help/suggestion welcome !            
tanuki66Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hongjunCommented:
It could also be due to your antivirus program.
Make sure you disable "Script Blocking".
0
tanuki66Author Commented:
thanks for your fast response, but "AV disabled" stood for "antivirus disabled".
sorry it was not clear !
0
peterxlaneCommented:
Create two subroutines with error trapping and see if you can get some sort of error description:

<%
Sub WriteMyFile
      On Error Resume Next
      Dim FSO, fichier,ligne,strpath
      strPath = Server.MapPath("testcmbp.txt")
      Set FSO = server.CreateObject("Scripting.FileSystemObject")

      Set fichier = FSO.Opentextfile(strpath,2,true)' 2:w  8:a
      fichier.writeline now()
      fichier.WriteLine "xavier"
      fichier.writeline String(50,"-")
      fichier.Close
      Set fichier=nothing
      set fso=nothing
            
      If Err.number <> 0 Then
            Response.Write "ERROR #: " & Err.number & "<br />"
            Response.Write "ERROR DESCRIPTION: " & Err.Description & "<br />"
      Else
            Response.Write "file created successfully<br />"
      End If      
End Sub       

Sub ReadMyFile
      On Error Resume Next
      Dim FSO, fichier,ligne,strpath
      strPath = Server.MapPath("testcmbp.txt")
      Set FSO = server.CreateObject("Scripting.FileSystemObject")
      set fichier=FSO.opentextfile(strpath,1,true)'1 : read
      something = 100 / 0
      do until fichier.atendofstream
      ligne=fichier.readline()
      response.write(ligne&"<br>")
      loop
      fichier.close
      Set fichier=nothing
      set fso=nothing

      If Err.number <> 0 Then
            Response.Write "ERROR #: " & Err.number & "<br />"
            Response.Write "ERROR DESCRIPTION: " & Err.Description & "<br />"
      Else
            Response.Write "file read successfully<br />"            
      End If      
End Sub       

Call WriteMyFile
Call ReadMyFile

%>  
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Cherukuri30Service EngineerCommented:
check the security options of the folder where you are trying to store the file. If this is the case give full permissions to the folder
0
Cherukuri30Service EngineerCommented:
sorry that should not be a problem ingnore it
0
tanuki66Author Commented:
Thks peterxlane , but that script makes the page's service hang in the middle of nowhere.
0
Cherukuri30Service EngineerCommented:
Ok do the below steps

1) open c:\inetpub
2) right click on wwwroot folder and select sharing and security option
3) Once the www properties window is opened then click on security tab
4) Click on add button and then add the usernames wish are starting with IUSR_computer name and IWAM_computer name
5) for both these users assign full permissions and click ok button

Now execute your script
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peterxlaneCommented:
I know everybody keeps saying it, but it has got to be a permissions issue if it is just hanging like that.  I think technically it is not an error, so my error trapping was not displaying an error.  Check and see if you have PermissionChecker installed on the server (I think it is actually part of IIS but most people have never used it).  Try running this code and I will bet that you don't have permission on the file..

<%
Set PermissionChecker = Server.CreateObject("MSWC.PermissionChecker")
strPathToCheck = Server.MapPath("testcmbp.txt")
If PermissionChecker.HasAccess(strPathToCheck) Then
      Response.Write "You have permission to view:" & strPathToCheck
Else
      Response.Write "You do not have permission to view: " & strPathToCheck
End If
Set PermissionChecker = Nothing
%>
0
Cherukuri30Service EngineerCommented:
peterxlane you mean to say the steps which gave are not the right way to sort this problem out? If so which is the best way to solve i am intrested to learn new concepts

thanks
0
peterxlaneCommented:
@Cherukuri30 - I think that the five steps you outlined above are most likely what would resolve the problem; however one of the first things that tanuki66 stated was that they had checked the file permissions, so I was going on the assumption that they had already done those five steps.  My first solution posted was an attempt to trap any errors that might have been occurring, but apparently not having access to a file is not an error.  My second solution should show definitively whether or not IUSER_<computername> has permission to access the file.  If it does in fact show that it does have the correct permissions, then we could focus our efforts elsewhere.  I actually learned about the PermissionChecker here at EE, so I figured I would pass it along.  Here is some more information about it:

http://www.microsoft.com/windows2000/en/server/IIs/default.asp?url=/windows2000/en/server/IIs/htm/asp/comp3hf8.htm



0
Cherukuri30Service EngineerCommented:
Thanks peterxlane i do agree with you, The best method is to trap the error and then solve it instead of doing it in traditional way.
0
kevp75Commented:
actually Cherukuri30, I've found that folder (NTFS) permissions do matter, in fact they override IIS security settings

best bet is to try out peters subs to trap the error
0
Cherukuri30Service EngineerCommented:
Thats right i am working out with peter's script for myself to learn more about it
0
peterxlaneCommented:
@all - what I discovered by running my own code is that if you don't have permission to access the file, then it will cause it to just hang.  I tested it by running this:

<%
Sub ReadMyFile
     On Error Resume Next
     Dim FSO, fichier,ligne,strpath
     strPath = "C:\boot.ini"
     Set FSO = server.CreateObject("Scripting.FileSystemObject")
     set fichier=FSO.opentextfile(strpath,1,true)'1 : read
     do until fichier.atendofstream
     ligne=fichier.readline()
     response.write(ligne&"<br>")
     loop
     fichier.close
     Set fichier=nothing
     set fso=nothing

     If Err.number <> 0 Then
          Response.Write "ERROR #: " & Err.number & "<br />"
          Response.Write "ERROR DESCRIPTION: " & Err.Description & "<br />"
     Else
          Response.Write "file read successfully<br />"          
     End If    
End Sub
%>

And since it didn't have permission to access that file, it just hung... Maybe the two could be combined together, something like this:

<%
Sub ReadMyFile
      On Error Resume Next
      Set PermissionChecker = Server.CreateObject("MSWC.PermissionChecker")
      Dim oFSO, oFile, strPath
      strPath = "C:\boot.ini"      
      If PermissionChecker.HasAccess(strPath) Then
            Response.Write "You have permission to view:" & strPath & "<br />"
            Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
            Set oFile = oFSO.opentextfile(strPath,1,true)
            Do Until oFile.atenDofstream
                  Response.Write oFile.ReadLine & "<br />"
            Loop
            oFile.Close
            Set oFile = Nothing
            Set oFSO = Nothing            
      Else
            Response.Write "You do not have permission to view: " & strPath & "<br />"
      End If
      If Err.Number <> 0 Then
            Response.Write "ERROR #: " & Err.Number & "<br />"
            Response.Write "ERROR DESCRIPTION: " & Err.Description & "<br />"
      End If      
End Sub       

Call ReadMyFile
%>


0
tanuki66Author Commented:
Thanks for so many suggestions, and keep cool, it's only about computers !
Well, first thing i tried was  peterxlane suggestion (script for file perms).
It works fine and confirms i do have the access right.

Then i followed Cherukuri30's suggestion and...yes the IWAM was missing.(had Admin and IUSR only).

Thanks a lot to all, you gave me a lot of pertinent informations.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.