Solved

ASP problem

Posted on 1997-09-05
6
166 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
  • 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now