Javascript as command line callable scripting language

前端 未结 6 376
野趣味
野趣味 2021-01-14 17:42

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\"         


        
相关标签:
6条回答
  • 2021-01-14 18:01

    Why do you want to do this in javascript? Why not use a language that is suitable for this type of command line environment such as Perl? Javascript's main purpose is to faciltate client-side browser control.

    0 讨论(0)
  • 2021-01-14 18:03

    Node.js has emerged as the clear winner here, at least for me.

    http://nodejs.org/

    0 讨论(0)
  • 2021-01-14 18:05

    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.

    0 讨论(0)
  • 2021-01-14 18:08

    Well, there's JScript.NET:

    http://www.devsource.com/c/a/Techniques/JScriptNET-Applications-at-the-Command-Line/1/

    0 讨论(0)
  • 2021-01-14 18:20

    With Phantom JS you can easily run a javascript from command line and it naively supports DOM, CSS Selector and JSON.

    0 讨论(0)
  • 2021-01-14 18:21

    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-common - Common modules for GNOME JavaScript interpreters
    
    0 讨论(0)
提交回复
热议问题