ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old June 20th, 2003, 05:36 AM
timzter timzter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 63 timzter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 39 sec
Reputation Power: 6
Cannot open and/or write to file from ASP code

For the life of me I still haven't gotten my ASP to write to a file on the local hard disk!! I am running IIS 5.0 on Win2K Advanced Server. All I am trying to do is to run the following ASP code which I saved into c:\acme\test.asp:

<%
dim filesys, filetxt
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set filesys = CreateObject("Scripting.FileSystemObject")
Set filetxt = filesys.OpenTextFile("c:\acme\somefile.txt", ForAppending, True)
filetxt.WriteLine("Hello World")
filetxt.Close
%>

When it comes to the OpenTextFile statement, the web browser just spins and spins and spins forever, until I stop it. (If I comment out that line and the lines below it, it is OK.) The file c:\acme\somefile.txt is never created.

I had created a Virtual Directory with an alias of 'acme' which points to the directory c:\acme. I entered the URL of:
http://localhost/acme/test.asp

Please tell me step by step what I must do to make the above ASP code write to the c:\acme\somefile.txt when I access the above URL. I have been struggling with this problem for over a week! :-(

Reply With Quote
  #2  
Old June 20th, 2003, 11:51 AM
Ed Woychowsky Ed Woychowsky is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Pennsylvania
Posts: 6 Ed Woychowsky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Permissions

You might want to open IIS and check folder permissions. By default, writing isn't enabled.

Reply With Quote
  #3  
Old June 20th, 2003, 01:36 PM
timzter timzter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 63 timzter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 39 sec
Reputation Power: 6
I didn't want to say what I did because I was hoping someone would tell me exactly what needs to be done to make it work. But I have actually tried several things, included adding "Write" permission to the Virtual Directory. I also did what some other websites suggested which is to right click on the c:\acme folder in Windows Explorer and select the Security folder tab and Add the user called IUSER_maestro (my machine name) and then edit the permissions to add Modify (which automatically adds Write as well), and then to also add ability for it to Delete files and folders as well. I did all that. It still doesn't work.

However, when I run the EXACT SAME asp file in Windows 98's Personal Web Server, it works WITHOUT my having to make any changes to the web server configuration settings. Personal Web Server is supposed to be inferior to IIS, but I am having a hell of a hard time making the above code (for writing to a file) work in IIS !! Please, if anyone has seen this problem before, please post the solution. Thanks.

Reply With Quote
  #4  
Old June 26th, 2003, 10:23 AM
tipy tipy is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 22 tipy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!
I have exactly the same problem as you timzter!!
I can't launch any ASP file in a browser.
I also use Win2K and IIS.
So, if someone can help us, that would be great!!
Thanks.

Reply With Quote
  #5  
Old June 26th, 2003, 08:04 PM
timzter timzter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 63 timzter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 39 sec
Reputation Power: 6
I *think* I discovered the problem which I have been having all this time. I *think* it is because I logged in to my Win2K as "Administrator", launched IIS as "Administrator", created the virtual directory to point to a real directory which was created as "Administrator". Basically "Administrator" rights everywhere. I was ABLE to browse pages served by the website I was testing with, but, as I said in my original question, Internet Explorer spins and spins and spins whenever the ASP code tries to write to the filesystem. My theory is that IIS is trying to exercise some security by not letting the file be created and written to by a script (ASP) running under port 80 from within IIS as "Administrator". However, in my office computer running Win2K I never had this problem because I log in to my my Win2K computer in the office as a regular User or possibly Power User (I haven't checked, but definitely not Administrator). Since this is more limiting and, therefore, more secure, IIS allows the ASP code to create the file (assuming also that the directory that the file is being created and written to was created by the user/power user, not by Administrator). I am in the process of reformatting my hard drive and reinstalling Win2K, so I haven't checked this theory out yet, but for those of you who claim my little ASP code (in the original question) works, see if it still works if you LOG IN as Administrator and create the directory where my ASP code resides AND writes the file to also as Administrator, and then access the URL on your browser and see if it still writes to the file.

Reply With Quote
  #6  
Old July 3rd, 2003, 08:57 PM
golmalgovindam golmalgovindam is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Los Angles
Posts: 1 golmalgovindam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just check if it matters having \\ instead of a single one in the path...I had a similar problem...
c:\\acme\\somefile.txt instead of
c:\acme\somefile.txt

Reply With Quote
  #7  
Old July 4th, 2003, 07:28 AM
timzter timzter is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 63 timzter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 2 m 39 sec
Reputation Power: 6
Looks like my problem was indeed due to having logged in as Administrator, having the directory where the virtual directory was pointing to be owned by Adminstrator. I recently reformatted my hard drive, and reinstalled Win2K Advanced Server. This is what I did:

1. As Administrator, I created a REGULAR User account, let's say, "foo".
2. Logged out as Administrator.
3. Logged in as user "foo".
4. Created a directory C:\foo to hold the files for the "foo" website. So this directory is owned by user foo and have regular user permissions.
5. Logged out as "foo".
6. Logged back in as Administrator.
7. Created a virtual directory called "foo" which points to C:\foo.
8. Logged out as Administrator.
9. Logged back in as user "foo".
10. Created the test ASP code in C:\foo....the same ASP code that was giving me problems with writing to a file.
11. Invoked the URL: http://localhost/foo/test.asp, and it WORKS without any problems.

So, I think the problem I had before was that I was doing EVERYTHING as Administrator, and this posed a security threat to the system to have a website running under port 80 have full Write permissions to the filesystem.

Or.......the problem could have been due to my running Norton Anti-Virus. I am not running it now. Someone else suggested that it might have been Norton Anti-Virus preventing scripts from writing to a file, and that that restriction had to be turned off first.

Reply With Quote
  #8  
Old August 6th, 2003, 03:12 AM
jcwatson11 jcwatson11 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 1 jcwatson11 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I have confirmed that disabling Norton Anti-Virus's Script Blocker takes care of the problem. I was experiencing the same problem with ASP pages only when trying to open a text stream. Disabling NAV's script blocker allowed IIS to use ASP "script" to open the file.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Cannot open and/or write to file from ASP code


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

IBM developerWorks




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway