bpatel | 87d64cc | 2010-07-14 15:42:06 -0700 | [diff] [blame] | 1 | ." Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 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 | ." |
ohair | 2283b9d | 2010-05-25 15:58:33 -0700 | [diff] [blame] | 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. |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 21 | ." |
bpatel | 87d64cc | 2010-07-14 15:42:06 -0700 | [diff] [blame] | 22 | .TH jrunscript 1 "02 Jun 2010" |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 23 | |
| 24 | .LP |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 25 | .SH "Name" |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 26 | jrunscript \- command line script shell |
| 27 | .LP |
| 28 | .SH "SYNOPSIS" |
| 29 | .LP |
| 30 | |
| 31 | .LP |
| 32 | .nf |
| 33 | \f3 |
| 34 | .fl |
| 35 | \fP\f3jrunscript\fP [ \f2options\fP ] [ arguments... ] |
| 36 | .fl |
| 37 | .fi |
| 38 | |
| 39 | .LP |
| 40 | .SH "PARAMETERS" |
| 41 | .LP |
| 42 | |
| 43 | .LP |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 44 | .RS 3 |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 45 | .TP 3 |
| 46 | options |
| 47 | Options, if used, should follow immediately after the command name. |
| 48 | .TP 3 |
| 49 | arguments |
| 50 | Arguments, if used, should follow immediately after options or command name. |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 51 | .RE |
| 52 | |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 53 | .LP |
| 54 | .SH "DESCRIPTION" |
| 55 | .LP |
| 56 | |
| 57 | .LP |
| 58 | .LP |
| 59 | \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. |
| 60 | .LP |
| 61 | .LP |
| 62 | \f3NOTE:\fP This tool is \f3experimental\fP and may \f3not\fP be available in future versions of the JDK. |
| 63 | .LP |
| 64 | .SH "OPTIONS" |
| 65 | .LP |
| 66 | |
| 67 | .LP |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 68 | .RS 3 |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 69 | .TP 3 |
| 70 | \-classpath path |
| 71 | Specify where to find the user's .class files that are accessed by the script. |
| 72 | .TP 3 |
| 73 | \-cp path |
| 74 | This is a synonym for \-classpath \f2path\fP |
| 75 | .TP 3 |
| 76 | \-Dname=value |
| 77 | Set a Java system property. |
| 78 | .TP 3 |
| 79 | \-J<flag> |
| 80 | Pass <flag> directly to the Java virtual machine on which jrunscript is run. |
| 81 | .TP 3 |
| 82 | \-l language |
| 83 | Use 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. |
| 84 | .TP 3 |
| 85 | \-e script |
| 86 | Evaluate the given script. This option can be used to run "one liner" scripts specified completely on the command line. |
| 87 | .TP 3 |
| 88 | \-encoding encoding |
| 89 | Specify the character encoding used while reading script files. |
| 90 | .TP 3 |
| 91 | \-f script\-file |
| 92 | Evaluate the given script file (batch mode). |
| 93 | .TP 3 |
| 94 | \-f \- |
| 95 | Read and evaluate a script from standard input (interactive mode). |
| 96 | .TP 3 |
| 97 | \-help\ |
| 98 | Output help message and exit. |
| 99 | .TP 3 |
| 100 | \-?\ |
| 101 | Output help message and exit. |
| 102 | .TP 3 |
| 103 | \-q\ |
| 104 | List all script engines available and exit. |
tbell | 16c34dd | 2009-05-04 18:28:26 -0700 | [diff] [blame] | 105 | .RE |
| 106 | |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 107 | .LP |
| 108 | .SH "ARGUMENTS" |
| 109 | .LP |
| 110 | .LP |
| 111 | If [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. |
| 112 | .LP |
| 113 | .SH "EXAMPLES" |
| 114 | .LP |
| 115 | \f3Executing inline scripts\fP |
| 116 | .LP |
| 117 | .RS 3 |
| 118 | |
| 119 | .LP |
| 120 | .nf |
| 121 | \f3 |
| 122 | .fl |
| 123 | jrunscript \-e "print('hello world')" |
| 124 | .fl |
| 125 | jrunscript \-e "cat('http://java.sun.com')" |
| 126 | .fl |
| 127 | \fP |
| 128 | .fi |
| 129 | .RE |
| 130 | |
| 131 | .LP |
| 132 | \f3Use specified language and evaluate given script file\fP |
| 133 | .LP |
| 134 | .RS 3 |
| 135 | |
| 136 | .LP |
| 137 | .nf |
| 138 | \f3 |
| 139 | .fl |
| 140 | jrunscript \-l js \-f test.js |
| 141 | .fl |
| 142 | \fP |
| 143 | .fi |
| 144 | .RE |
| 145 | |
| 146 | .LP |
| 147 | \f3Interactive mode\fP |
| 148 | .LP |
| 149 | .RS 3 |
| 150 | |
| 151 | .LP |
| 152 | .nf |
| 153 | \f3 |
| 154 | .fl |
| 155 | jrunscript |
| 156 | .fl |
| 157 | js>print('hello world'); |
| 158 | .fl |
| 159 | hello world |
| 160 | .fl |
| 161 | js>34 + 55 |
| 162 | .fl |
| 163 | 89 |
| 164 | .fl |
| 165 | js> thread(function() { print('hello world'); } |
| 166 | .fl |
| 167 | hello world |
| 168 | .fl |
| 169 | js> |
| 170 | .fl |
| 171 | \fP |
| 172 | .fi |
| 173 | .RE |
| 174 | |
| 175 | .LP |
| 176 | \f3Run script file with script arguments\fP |
| 177 | .LP |
| 178 | .RS 3 |
| 179 | |
| 180 | .LP |
| 181 | .nf |
| 182 | \f3 |
| 183 | .fl |
| 184 | jrunscript test.js arg1 arg2 arg3 |
| 185 | .fl |
| 186 | \fP |
| 187 | .fi |
| 188 | .RE |
| 189 | |
| 190 | .LP |
| 191 | test.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. |
| 192 | .SH "SEE ALSO" |
| 193 | .LP |
| 194 | .LP |
| 195 | If 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 jsdocs. |
| 196 | .LP |
duke | 6e45e10 | 2007-12-01 00:00:00 +0000 | [diff] [blame] | 197 | |