admin管理员组文章数量:1425966
I'm looking for a way to write some simple scripts in javascript, like I would in ruby. For example, I might write a script like:
var str = "Hello World";
console.log(str);
And i want to able to call it from my mand line like this:
js hello_world.js
Is there some sort of Javascript runtime, that includes a standard library that would allow me to do this style of script development? I know there is node.js, but that is specific to a web server, right?
I'm looking for a way to write some simple scripts in javascript, like I would in ruby. For example, I might write a script like:
var str = "Hello World";
console.log(str);
And i want to able to call it from my mand line like this:
js hello_world.js
Is there some sort of Javascript runtime, that includes a standard library that would allow me to do this style of script development? I know there is node.js, but that is specific to a web server, right?
Share Improve this question asked Jan 18, 2011 at 4:27 Alex WayneAlex Wayne 188k52 gold badges328 silver badges360 bronze badges 2- 1 No, node.js is not specific to a web server. – icktoofay Commented Jan 18, 2011 at 4:41
- possible duplicate of Running javascript standalone engine? – Helen Commented Jan 18, 2011 at 9:27
6 Answers
Reset to default 5Node.js has emerged as the clear winner here, at least for me.
http://nodejs/
Well, there's JScript.NET:
http://www.devsource./c/a/Techniques/JScriptNET-Applications-at-the-Command-Line/1/
As mentioned in this previous question, you might want to check out Rhino, an implementation of Javascript written in Java. Specifically, the page on the JavaScript shell might be of interest.
Hope this helps.
what about mozilla's spidermonkey ?
apt-cache search javascript interpreter
spidermonkey-bin - standalone JavaScript/ECMAScript (ECMA-262) interpreter
libjenkins-htmlunit-core-js-java - Jenkins branch of the HtmlUnit Core JS Interpreter
gnome-js-mon - Common modules for GNOME JavaScript interpreters
With Phantom JS you can easily run a javascript from mand line and it naively supports DOM, CSS Selector and JSON.
Why do you want to do this in javascript? Why not use a language that is suitable for this type of mand line environment such as Perl? Javascript's main purpose is to faciltate client-side browser control.
本文标签: Javascript as command line callable scripting languageStack Overflow
版权声明:本文标题:Javascript as command line callable scripting language - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745395961a2656814.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论