Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
becki:linux:jrunscript [2011-03-10 16:14] becki |
becki:linux:jrunscript [2011-03-22 13:55] (aktuell) becki |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== jrunscipt - Javascript from the Command Line == | + | ====== Standalone Javascript == |
- | 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. | + | This page is about [[http://www.mozilla.org/rhino/|Rhino]], the scripting engine that comes with Java 1.6. |
- | ===== Usage == | + | ===== Basic Usage == |
jrunscript scriptfile.js arg1 arg2 ... | jrunscript scriptfile.js arg1 arg2 ... | ||
<note important>Using a shebang like ''!#/usr/lib/java/bin/jrunscript'' doesn't work so far!</note> | <note important>Using a shebang like ''!#/usr/lib/java/bin/jrunscript'' doesn't work so far!</note> | ||
+ | |||
+ | ''jrunscript -q'' reveals the version of Rhino. | ||
See also the [[http://download.oracle.com/javase/6/docs/technotes/tools/share/jrunscript.html|manpage]] | See also the [[http://download.oracle.com/javase/6/docs/technotes/tools/share/jrunscript.html|manpage]] | ||
Zeile 13: | Zeile 15: | ||
===== Built-in global Properties and Functions == | ===== Built-in global Properties and Functions == | ||
- | Did not find a complete document yet. See [[http://www.herongyang.com/JavaScript/Built-In-Object-Global-Properties-and-Functions-jrunscript.html|Global Properties and Functions]], [[http://www.silab.dsi.unimi.it/manual/JDK%206%20Documentation/technotes/tools/share/jsdocs/index.html|jrunscript JavaScript built-ins]] ([[http://download.oracle.com/javase/7/docs/technotes/tools/share/jsdocs/GLOBALS.html|alternaltive]]) | + | Did not find a complete document yet. The [[http://www.silab.dsi.unimi.it/manual/JDK%206%20Documentation/technotes/tools/share/jsdocs/index.html|jrunscript JavaScript built-ins]] ([[http://download.oracle.com/javase/7/docs/technotes/tools/share/jsdocs/GLOBALS.html|alternaltive]]) are not complete (e.g. print() / println() are missing). The functions listed in [[https://developer.mozilla.org/en/Rhino_Shell|Rhino Shell]] are obviously not in sync with jrunsricpt (e.g. ''readFile()'' is not available). |
+ | |||
+ | The IMHO only way to really find out which functions you have is to have a script print out the functions. This is described here: [[http://www.herongyang.com/JavaScript/Built-In-Object-Global-Properties-and-Functions-jrunscript.html|Global Properties and Functions]]. Here is a shortcut: | ||
- | Note that ''print'' and ''println'' is somehow not documented in the Built-ins. | + | jrunscript -e 'for (i in this) echo("/** "+i+" */", this[i])' |
===== Interaction with the underlying OS == | ===== Interaction with the underlying OS == |