J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | .'" t |
| 2 | ." Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
| 3 | ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | ." |
| 5 | ." This code is free software; you can redistribute it and/or modify it |
| 6 | ." under the terms of the GNU General Public License version 2 only, as |
| 7 | ." published by the Free Software Foundation. |
| 8 | ." |
| 9 | ." This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | ." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | ." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | ." version 2 for more details (a copy is included in the LICENSE file that |
| 13 | ." accompanied this code). |
| 14 | ." |
| 15 | ." You should have received a copy of the GNU General Public License version |
| 16 | ." 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | ." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | ." |
| 19 | ." Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 20 | ." CA 95054 USA or visit www.sun.com if you need additional information or |
| 21 | ." have any questions. |
| 22 | ." ` |
| 23 | .TH jrunscript 1 "06 Aug 2006" |
| 24 | ." Generated by html2man |
| 25 | |
| 26 | .LP |
| 27 | .SH NAME |
| 28 | jrunscript \- command line script shell |
| 29 | .LP |
| 30 | .SH "SYNOPSIS" |
| 31 | .LP |
| 32 | |
| 33 | .LP |
| 34 | .nf |
| 35 | \f3 |
| 36 | .fl |
| 37 | \fP\f3jrunscript\fP [ \f2options\fP ] [ arguments... ] |
| 38 | .fl |
| 39 | .fi |
| 40 | |
| 41 | .LP |
| 42 | .SH "PARAMETERS" |
| 43 | .LP |
| 44 | |
| 45 | .LP |
| 46 | .TP 3 |
| 47 | options |
| 48 | Options, if used, should follow immediately after the command name. |
| 49 | .TP 3 |
| 50 | arguments |
| 51 | Arguments, if used, should follow immediately after options or command name. |
| 52 | .LP |
| 53 | .SH "DESCRIPTION" |
| 54 | .LP |
| 55 | |
| 56 | .LP |
| 57 | .LP |
| 58 | \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. |
| 59 | .LP |
| 60 | .LP |
| 61 | \f3NOTE:\fP This tool is \f3experimental\fP and may \f3not\fP be available in future versions of the JDK. |
| 62 | .LP |
| 63 | .SH "OPTIONS" |
| 64 | .LP |
| 65 | |
| 66 | .LP |
| 67 | .TP 3 |
| 68 | \-classpath path |
| 69 | Specify where to find the user's .class files that are accessed by the script. |
| 70 | .TP 3 |
| 71 | \-cp path |
| 72 | This is a synonym for \-classpath \f2path\fP |
| 73 | .TP 3 |
| 74 | \-Dname=value |
| 75 | Set a Java system property. |
| 76 | .TP 3 |
| 77 | \-J<flag> |
| 78 | Pass <flag> directly to the Java virtual machine on which jrunscript is run. |
| 79 | .TP 3 |
| 80 | \-l language |
| 81 | 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. |
| 82 | .TP 3 |
| 83 | \-e script |
| 84 | Evaluate the given script. This option can be used to run "one liner" scripts specified completely on the command line. |
| 85 | .TP 3 |
| 86 | \-encoding encoding |
| 87 | Specify the character encoding used while reading script files. |
| 88 | .TP 3 |
| 89 | \-f script\-file |
| 90 | Evaluate the given script file (batch mode). |
| 91 | .TP 3 |
| 92 | \-f \- |
| 93 | Read and evaluate a script from standard input (interactive mode). |
| 94 | .TP 3 |
| 95 | \-help\ |
| 96 | Output help message and exit. |
| 97 | .TP 3 |
| 98 | \-?\ |
| 99 | Output help message and exit. |
| 100 | .TP 3 |
| 101 | \-q\ |
| 102 | List all script engines available and exit. |
| 103 | .LP |
| 104 | .SH "ARGUMENTS" |
| 105 | .LP |
| 106 | .LP |
| 107 | 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. |
| 108 | .LP |
| 109 | .SH "EXAMPLES" |
| 110 | .LP |
| 111 | \f3Executing inline scripts\fP |
| 112 | .LP |
| 113 | .RS 3 |
| 114 | |
| 115 | .LP |
| 116 | .nf |
| 117 | \f3 |
| 118 | .fl |
| 119 | jrunscript \-e "print('hello world')" |
| 120 | .fl |
| 121 | jrunscript \-e "cat('http://java.sun.com')" |
| 122 | .fl |
| 123 | \fP |
| 124 | .fi |
| 125 | .RE |
| 126 | |
| 127 | .LP |
| 128 | \f3Use specified language and evaluate given script file\fP |
| 129 | .LP |
| 130 | .RS 3 |
| 131 | |
| 132 | .LP |
| 133 | .nf |
| 134 | \f3 |
| 135 | .fl |
| 136 | jrunscript \-l js \-f test.js |
| 137 | .fl |
| 138 | \fP |
| 139 | .fi |
| 140 | .RE |
| 141 | |
| 142 | .LP |
| 143 | \f3Interactive mode\fP |
| 144 | .LP |
| 145 | .RS 3 |
| 146 | |
| 147 | .LP |
| 148 | .nf |
| 149 | \f3 |
| 150 | .fl |
| 151 | jrunscript |
| 152 | .fl |
| 153 | js>print('hello world'); |
| 154 | .fl |
| 155 | hello world |
| 156 | .fl |
| 157 | js>34 + 55 |
| 158 | .fl |
| 159 | 89 |
| 160 | .fl |
| 161 | js> thread(function() { print('hello world'); } |
| 162 | .fl |
| 163 | hello world |
| 164 | .fl |
| 165 | js> |
| 166 | .fl |
| 167 | \fP |
| 168 | .fi |
| 169 | .RE |
| 170 | |
| 171 | .LP |
| 172 | \f3Run script file with script arguments\fP |
| 173 | .LP |
| 174 | .RS 3 |
| 175 | |
| 176 | .LP |
| 177 | .nf |
| 178 | \f3 |
| 179 | .fl |
| 180 | jrunscript test.js arg1 arg2 arg3 |
| 181 | .fl |
| 182 | \fP |
| 183 | .fi |
| 184 | .RE |
| 185 | |
| 186 | .LP |
| 187 | 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. |
| 188 | .SH "SEE ALSO" |
| 189 | .LP |
| 190 | .LP |
| 191 | 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. |
| 192 | .LP |
| 193 | |
| 194 | .LP |
| 195 | |