Solved

ASP problem

Posted on 1997-09-05
6
171 Views
Last Modified: 2013-12-25
Using JavaScript, the CreateTextFile()/OpenTextFile()
does not work right. It always gives me "Permission Denied" when I try
to create a file. But the same thing works fine with VBScript. Can you
tell me what's wrong that I'm doing ?
0
Comment
Question by:vsp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 2

Accepted Solution

by:
theTerabyte earned 100 total points
ID: 1854947
the problem is JavaScript is a very security-concious language.  There are many things it won't let you do since it runs on a client machine.  I believe those commands would open a text file on the client's machine, not the server, and there are unly certain places you can access files from to prevent a breach in security, otherwise people would write scripts to ready the /etc/passwd file on uni machines and get passwords, or modify windows stuff.
I BELIEVE if you create a text file, you have the perms to read it, but i don't know.

The point is, the reason you can't do it in favascript but can in others is JavaScript's security features.

HOPE THIS HELPS, (the)Terabyte
0
 

Author Comment

by:vsp
ID: 1854948
I wish, the answer would have told me how to create the text file in JavaScript. It is a rather incomplete answer.
0
 
LVL 2

Expert Comment

by:theTerabyte
ID: 1854949
sorry, let me look at it and try to give you more info....
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 2

Expert Comment

by:theTerabyte
ID: 1854950
Explain how CreateTextFile() and OpenTextFile() is supposed to work, i.e. arguments and such, and i'll try to figure out why it won't work.  It must be the ONE function not covered in my JS book.  However, I was able to answer you question(kinda) from general JavaScript history and knoledge about the history of the language.  
One of the main reasons many browsers didn't support JS or Java until recently is because they were worried it wasn't secure enough, it is someone's program who you don't know that is running on unsuspecting client's machines.  That's why netscape by default warns you about JS and Java, and it can be disabled.  The first versions were pretty buggy and it was very possible, especially in Java, that one could read file of a client's hard drive or network and relay them to a server(uhh oh).  But, as you know can see, those "problems" have been fixed for the most part(i.e. perm errors).
0
 

Author Comment

by:vsp
ID: 1854951
I appreciate your concern on answering my question, thanks !
The CreateTextFile() is supposed to create a text file with these arguments;
      CreateTextFile ("fname",createFlag,permissions)
where:
      createFlag - create a file if non-exsistant, otherwise overwrite.
      permissions- permissions given to the file

FYI-This works okay in VBScript with any combinations of these arguments.

With OpenTextFile(), the story is stightly different.It does not work in JScript but in VBScript these two forms do not work

      Set tf = fs.OpenTextFile ("e:\textFile.txt",1,TRUE,0)

In these it complains of invalid argument TRUE.

      Set tf = fs.OpenTextFile("e:\txtFile.txt", 0,0,0)
      tf.WriteLine("This is a test")

It says "Permission Denied". In this case we are trying to append to a pre-exsistant file.

I have added lot of extra infomation in this comment, which may help you debug the problem.

Thanks, in advance.
0
 
LVL 2

Expert Comment

by:theTerabyte
ID: 1854952
Alright, i've sone some testing, and i'm sorry to say, I don't know why it dosen't work or how to fix it, but I do know the reason is related to JS' Security features.  To do any more testing i'd need the HTML file you're using it in.  If you can send it to me, i might be able to look at it again.....
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question