Reputation: 5164
I have written some javascript which reads data in a textarea (inside a browser) and outputs the result in a string (as innerHTML) in a div.
It's brilliant and it does its job.
I would like to port it out of the browser.
I would like to reuse the same javascript (which effectively is just a function that given a string returns another string) out of the browser.
Ideally I would like to run it a commandline tool and say read file c:\input.txt and writes the response on c:\output.txt
Can somebody suggest how best I can achieve this ?
I looked around and came across to commonjs.org (which is very interesting) and node.js (which is interesting too) as well as other obscure projects.
Yet, I still don't know how to do this. If somebody has done something similar I would like to hear.
Many Thanks,
p.s. I tagged this question 'server-side javascript' mainly to say that it's not a browser question.
Upvotes: 0
Views: 577
Reputation: 1361
It's a thin wrapper on top of Rhino. Makes dealing with files, modules, etc a lot easier, see for example: http://ringojs.org/api/master/fs/
Upvotes: 0
Reputation: 122906
If your're on a windows system, you could the native c-/wscript interpreter using the FileSystemObject to read and write files. Otherwise jsdb may be an option, where you can use the Stream
-object.
Upvotes: 1