Dies ist eine alte Version des Dokuments!
The jrunscipt
command comes with Java 1.6. Use it to call javascript files from the command line. The Rhino scripting engine is used as default.
jrunscript scriptfile.js arg1 arg2 ...
!#/usr/lib/java/bin/jrunscript
doesn't work so far!
See also the manpage
Did not find a complete document yet. See Global Properties and Functions, jrunscript JavaScript built-ins (alternaltive)
Note that print
and println
is somehow not documented in the Built-ins.
Use the predefined arguments
array:
for (var i=0; i<arguments.length; i++) println('Arg '+ i+ ' '+ arguments[i]);
exit(code)
echo('Hello world!'); println('Hello World!'); print('Hello World!\n'); printf('Hello World!\n');
use
read
From within a Webbrowser, you have access to the DOM API whereas from jrunscript (with Rhino) you have access to the jrunscript Built-ins and the Java-API. The only intersection are the javascript built in core functions and objects.
In order to support both a CLI- and a Web frontend one should separate the frontend-specific code from the generic application code:
cli.js <---. |--- core_app.js html_dom.js <---´
load('core_app.js') core_app() // function is defined in core_app.js