jrunscript.1 revision 6073:cea72c2bf071
1." Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. 2." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3." 4." This code is free software; you can redistribute it and/or modify it 5." under the terms of the GNU General Public License version 2 only, as 6." published by the Free Software Foundation. 7." 8." This code is distributed in the hope that it will be useful, but WITHOUT 9." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11." version 2 for more details (a copy is included in the LICENSE file that 12." accompanied this code). 13." 14." You should have received a copy of the GNU General Public License version 15." 2 along with this work; if not, write to the Free Software Foundation, 16." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17." 18." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19." or visit www.oracle.com if you need additional information or have any 20." questions. 21." 22.TH jrunscript 1 "10 May 2011" 23 24.LP 25.SH "Name" 26jrunscript \- command line script shell 27.LP 28.SH "SYNOPSIS" 29.LP 30.nf 31\f3 32.fl 33\fP\f3jrunscript\fP [ \f2options\fP ] [ arguments... ] 34.fl 35.fi 36 37.LP 38.SH "PARAMETERS" 39.LP 40.RS 3 41.TP 3 42options 43Options, if used, should follow immediately after the command name. 44.TP 3 45arguments 46Arguments, if used, should follow immediately after options or command name. 47.RE 48 49.LP 50.SH "DESCRIPTION" 51.LP 52.LP 53\f3jrunscript\fP is a command line script shell. jrunscript supports both an interactive (read\-eval\-print) mode and a batch (\-f option) mode of script execution. This is a scripting language independent shell. By default, JavaScript is the language used, but the \-l option can be used to specify a different language. Through Java to scripting language communication, jrunscript supports "exploratory programming" style. 54.LP 55.LP 56\f3NOTE:\fP This tool is \f3experimental\fP and may \f3not\fP be available in future versions of the JDK. 57.LP 58.SH "OPTIONS" 59.LP 60.RS 3 61.TP 3 62\-classpath path 63Specify where to find the user's .class files that are accessed by the script. 64.TP 3 65\-cp path 66This is a synonym for \-classpath \f2path\fP 67.TP 3 68\-Dname=value 69Set a Java system property. 70.TP 3 71\-J<flag> 72Pass <flag> directly to the Java virtual machine on which jrunscript is run. 73.TP 3 74\-l language 75Use the specified scripting language. By default, JavaScript is used. Note that to use other scripting languages, you also need to specify the corresponding script engine's jar file using \-cp or \-classpath option. 76.TP 3 77\-e script 78Evaluate the given script. This option can be used to run "one liner" scripts specified completely on the command line. 79.TP 3 80\-encoding encoding 81Specify the character encoding used while reading script files. 82.TP 3 83\-f script\-file 84Evaluate the given script file (batch mode). 85.TP 3 86\-f \- 87Read and evaluate a script from standard input (interactive mode). 88.TP 3 89\-help\ 90Output help message and exit. 91.TP 3 92\-?\ 93Output help message and exit. 94.TP 3 95\-q\ 96List all script engines available and exit. 97.RE 98 99.LP 100.SH "ARGUMENTS" 101.LP 102.LP 103If [arguments...] are present and if no \f3\-e\fP or \f3\-f\fP option is used, then the first argument is the script file and the rest of the arguments, if any, are passed as script arguments. If [arguments..] and \f3\-e\fP or \f3\-f\fP option are used, then all [arguments..] are passed as script arguments. If [arguments..], \f3\-e\fP and \f3\-f\fP are missing, interactive mode is used. Script arguments are available to a script in an engine variable named "arguments" of type String array. 104.LP 105.SH "EXAMPLES" 106.LP 107.SS 108Executing inline scripts 109.LP 110.nf 111\f3 112.fl 113jrunscript \-e "print('hello world')" 114.fl 115jrunscript \-e "cat('http://java.sun.com')" 116.fl 117\fP 118.fi 119 120.LP 121.SS 122Use specified language and evaluate given script file 123.LP 124.nf 125\f3 126.fl 127jrunscript \-l js \-f test.js 128.fl 129\fP 130.fi 131 132.LP 133.SS 134Interactive mode 135.LP 136.nf 137\f3 138.fl 139jrunscript 140.fl 141js> print('Hello World\\n'); 142.fl 143Hello World 144.fl 145js> 34 + 55 146.fl 14789.0 148.fl 149js> t = new java.lang.Thread(function() { print('Hello World\\n'); }) 150.fl 151Thread[Thread\-0,5,main] 152.fl 153js> t.start() 154.fl 155js> Hello World 156.fl 157 158.fl 159js> 160.fl 161\fP 162.fi 163 164.LP 165.SS 166Run script file with script arguments 167.LP 168.nf 169\f3 170.fl 171jrunscript test.js arg1 arg2 arg3 172.fl 173\fP 174.fi 175 176.LP 177test.js is script file to execute and arg1, arg2 and arg3 are passed to script as script arguments. Script can access these using "arguments" array. 178.SH "SEE ALSO" 179.LP 180.LP 181If JavaScript is used, then before evaluating any user defined script, jrunscript initializes certain built\-in functions and objects. These JavaScript built\-ins are documented in 182.na 183\f2jsdocs\fP @ 184.fi 185http://download.oracle.com/javase/7/docs/technotes/tools/share/jsdocs/allclasses\-noframe.html. 186.LP 187 188