LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-23-2000, 11:01 AM   #1
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Rep: Reputation: 40

Can someone tell me what the following code, almost directly from a tutorial fails.
I have a two files on the server to test file access VIA javascript. Both files, source.txt and target.txt, are created with total read/write access to test the script.
It errors: 'FILE' is undefined.
Thanks in advance for any input.


code:
-----------------------------------
<script language="Javascript">
// Create the source File object

source = new File("source.txt")

// If the source file opens successfully, create a target file
if (source.open("r")) {
target = new File("target.txt")
target.open("w")

// Copy the source file to the target
while (!source.eof()) {
data = File.byteToString(source.readByte())
target.write(data);
}
source.close()
}
target.close()

</script>
------------------------------------

-- L. James
 
Old 08-23-2000, 12:39 PM   #2
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
If you use <script language="Javascript 1.2"> it doesn't give you an error message, although it doesn't seem to work either. Did you get the example from http://docs.iplanet.com/docs/manuals...jsref/file.htm?
 
Old 08-23-2000, 01:13 PM   #3
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
I don't recall where I got the script from. However, I see the exact script is there. Would you be able to make that script work (the one on the site)?
By the way, adding the:

language="Javascript 1.2"

to the simpliest script causes it not to work. For instance the following will work until the "1.2".

<script language="javascript">
document.write("Hello world">
</script>

Oh yea, another, "by the way", I notice that I posted the original message in the wrong area. I meant to post it under Programming... If you like I can look for an followups there.

-- L. James
 
Old 08-23-2000, 01:18 PM   #4
jeremy
root
 
Registered: Jun 2000
Distribution: Debian, Red Hat, Slackware, Fedora, Ubuntu
Posts: 13,597

Rep: Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080Reputation: 4080
I moved the thread for you.
 
Old 08-27-2000, 11:25 AM   #5
kill-hup
Member
 
Registered: Aug 2000
Location: NY - USA
Distribution: Slackware
Posts: 109

Rep: Reputation: 15
Client-Side Vs Server-Side

This may be a dumb question, but are you using that script on the server side? AFAIK, that script will not work in a client's browser - it has to be used as part of a server-side implementation.

(There is no "File" object in the Client-Side spec, that is what lead me to believe you were attempting to use it on the client's side.)
 
Old 08-27-2000, 04:01 PM   #6
Larry James
Member
 
Registered: Jun 2000
Location: Buffalo, New York
Distribution: Ubuntu, Raspbian
Posts: 381

Original Poster
Rep: Reputation: 40
The script was being used on the server side.
Thanks for the input. After further studying, I learned that this seems to be some special proprietary feature of the iplanet server.

-- L. James
 
Old 08-28-2000, 12:01 AM   #7
eraser
Member
 
Registered: Aug 2000
Location: US
Posts: 47

Rep: Reputation: 15
Thumbs up

Larry James
I just have a suggestion, why not use perl?
Perl is known be to great for handling files, and it's very easy to learn!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Access unix shell using php or javascript BlackHatRob Linux - General 4 11-06-2005 10:14 PM
Isolating read access to only to one file only by another file. jon_k Linux - Software 3 08-14-2004 05:16 AM
JavaScript error when trying to play media player file degraffenried13 Linux - General 0 07-24-2004 08:29 AM
javascript-lang-File for gtksourceview hihat Programming 0 03-02-2004 12:08 PM
Cant access LQ with javascript enabled BajaNick General 1 11-19-2003 07:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:42 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration