• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 177
  • Last Modified:

ASP problem

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
vsp
Asked:
vsp
  • 4
  • 2
1 Solution
 
theTerabyteCommented:
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
 
vspAuthor Commented:
I wish, the answer would have told me how to create the text file in JavaScript. It is a rather incomplete answer.
0
 
theTerabyteCommented:
sorry, let me look at it and try to give you more info....
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
theTerabyteCommented:
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
 
vspAuthor Commented:
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
 
theTerabyteCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now