1 ." Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. |
1 '\" t |
2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
2 .\" Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. |
3 ." |
3 .\" |
4 ." This code is free software; you can redistribute it and/or modify it |
4 .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5 ." under the terms of the GNU General Public License version 2 only, as |
5 .\" |
6 ." published by the Free Software Foundation. |
6 .\" This code is free software; you can redistribute it and/or modify it |
7 ." |
7 .\" under the terms of the GNU General Public License version 2 only, as |
8 ." This code is distributed in the hope that it will be useful, but WITHOUT |
8 .\" published by the Free Software Foundation. |
9 ." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9 .\" |
10 ." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
10 .\" This code is distributed in the hope that it will be useful, but WITHOUT |
11 ." version 2 for more details (a copy is included in the LICENSE file that |
11 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12 ." accompanied this code). |
12 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
13 ." |
13 .\" version 2 for more details (a copy is included in the LICENSE file that |
14 ." You should have received a copy of the GNU General Public License version |
14 .\" accompanied this code). |
15 ." 2 along with this work; if not, write to the Free Software Foundation, |
15 .\" |
16 ." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
16 .\" You should have received a copy of the GNU General Public License version |
17 ." |
17 .\" 2 along with this work; if not, write to the Free Software Foundation, |
18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
18 .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
19 ." or visit www.oracle.com if you need additional information or have any |
19 .\" |
20 ." questions. |
20 .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
21 ." |
21 .\" or visit www.oracle.com if you need additional information or have any |
22 .TH jrunscript 1 "10 May 2011" |
22 .\" questions. |
|
23 .\" |
|
24 .\" Arch: generic |
|
25 .\" Software: JDK 8 |
|
26 .\" Date: 21 November 2013 |
|
27 .\" SectDesc: Scripting Tools |
|
28 .\" Title: jrunscript.1 |
|
29 .\" |
|
30 .if n .pl 99999 |
|
31 .TH jrunscript 1 "21 November 2013" "JDK 8" "Scripting Tools" |
|
32 .\" ----------------------------------------------------------------- |
|
33 .\" * Define some portability stuff |
|
34 .\" ----------------------------------------------------------------- |
|
35 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
36 .\" http://bugs.debian.org/507673 |
|
37 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
|
38 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
39 .ie \n(.g .ds Aq \(aq |
|
40 .el .ds Aq ' |
|
41 .\" ----------------------------------------------------------------- |
|
42 .\" * set default formatting |
|
43 .\" ----------------------------------------------------------------- |
|
44 .\" disable hyphenation |
|
45 .nh |
|
46 .\" disable justification (adjust text to left margin only) |
|
47 .ad l |
|
48 .\" ----------------------------------------------------------------- |
|
49 .\" * MAIN CONTENT STARTS HERE * |
|
50 .\" ----------------------------------------------------------------- |
23 |
51 |
24 .LP |
52 .SH NAME |
25 .SH "Name" |
53 jrunscript \- Runs a command-line script shell that supports interactive and batch modes\&. This command is experimental and unsupported\&. |
26 jrunscript \- command line script shell |
54 .SH SYNOPSIS |
27 .LP |
55 .sp |
28 .SH "SYNOPSIS" |
56 .nf |
29 .LP |
|
30 .nf |
|
31 \f3 |
|
32 .fl |
|
33 \fP\f3jrunscript\fP [ \f2options\fP ] [ arguments... ] |
|
34 .fl |
|
35 .fi |
|
36 |
57 |
37 .LP |
58 \fBjrunscript\fR [\fIoptions\fR] [\fIarguments\fR] |
38 .SH "PARAMETERS" |
59 .fi |
39 .LP |
60 .sp |
40 .RS 3 |
61 .TP |
41 .TP 3 |
62 \fIoptions\fR |
42 options |
63 The command-line options\&. See Options\&. |
43 Options, if used, should follow immediately after the command name. |
64 .TP |
44 .TP 3 |
65 \fIarguments\fR |
45 arguments |
66 Arguments, when used, follow immediately after options or the command name\&. See Arguments\&. |
46 Arguments, if used, should follow immediately after options or command name. |
67 .SH DESCRIPTION |
|
68 The \f3jrunscript\fR command is a language-independent command-line script shell\&. The \f3jrunscript\fR command supports both an interactive (read-eval-print) mode and a batch (\f3-f\fR option) mode of script execution\&. By default, JavaScript is the language used, but the \f3-l\fR option can be used to specify a different language\&. By using Java to scripting language communication, the \f3jrunscript\fR command supports an exploratory programming style\&. |
|
69 .SH OPTIONS |
|
70 .TP |
|
71 -classpath \fIpath\fR |
|
72 .br |
|
73 Indicate where any class files are that the script needs to access\&. |
|
74 .TP |
|
75 -cp \fIpath\fR |
|
76 .br |
|
77 Same as \f3-classpath\fR\f3path\fR\&. |
|
78 .TP |
|
79 -D\fIname\fR=\fIvalue\fR |
|
80 .br |
|
81 Sets a Java system property\&. |
|
82 .TP |
|
83 -J\fIflag\fR |
|
84 .br |
|
85 Passes \f3flag\fR directly to the Java Virtual Machine where the \f3jrunscript\fR command is running\&. |
|
86 .TP |
|
87 -I \fIlanguage\fR |
|
88 .br |
|
89 Uses the specified scripting language\&. By default, JavaScript is used\&. To use other scripting languages, you must specify the corresponding script engine\&'s JAR file with the \f3-cp\fR or \f3-classpath\fR option\&. |
|
90 .TP |
|
91 -e \fIscript\fR |
|
92 .br |
|
93 Evaluates the specified script\&. This option can be used to run one-line scripts that are specified completely on the command line\&. |
|
94 .TP |
|
95 -encoding \fIencoding\fR |
|
96 .br |
|
97 Specifies the character encoding used to read script files\&. |
|
98 .TP |
|
99 -f \fIscript-file\fR |
|
100 .br |
|
101 Evaluates the specified script file (batch mode)\&. |
|
102 .TP |
|
103 -f - |
|
104 .br |
|
105 Reads and evaluates a script from standard input (interactive mode)\&. |
|
106 .TP |
|
107 -help |
|
108 .br |
|
109 Displays a help message and exits\&. |
|
110 .TP |
|
111 -? |
|
112 .br |
|
113 Displays a help message and exits\&. |
|
114 .TP |
|
115 -q |
|
116 .br |
|
117 Lists all script engines available and exits\&. |
|
118 .SH ARGUMENTS |
|
119 If arguments are present and if no \f3-e\fR or \f3-f\fR option is used, then the first argument is the script file and the rest of the arguments, if any, are passed to the script\&. If arguments and \f3-e\fR or the \f3-f\fR option are used, then all arguments are passed to the script\&. If arguments, \f3-e\fR and \f3-f\fR are missing, then interactive mode is used\&. Script arguments are available to a script in an engine variable named \f3arguments\fR of type \f3String\fR array\&. |
|
120 .SH EXAMPLES |
|
121 .SS EXECUTE\ INLINE\ SCRIPTS |
|
122 .sp |
|
123 .nf |
|
124 \f3jrunscript \-e "print(\&'hello world\&')"\fP |
|
125 .fi |
|
126 .nf |
|
127 \f3jrunscript \-e "cat(\&'http://www\&.example\&.com\&')"\fP |
|
128 .fi |
|
129 .nf |
|
130 \f3\fP |
|
131 .fi |
|
132 .sp |
|
133 .SS USE\ SPECIFIED\ LANGUAGE\ AND\ EVALUATE\ THE\ SCRIPT\ FILE |
|
134 .sp |
|
135 .nf |
|
136 \f3jrunscript \-l js \-f test\&.js\fP |
|
137 .fi |
|
138 .nf |
|
139 \f3\fP |
|
140 .fi |
|
141 .sp |
|
142 .SS INTERACTIVE\ MODE |
|
143 .sp |
|
144 .nf |
|
145 \f3jrunscript\fP |
|
146 .fi |
|
147 .nf |
|
148 \f3js> print(\&'Hello World\en\&');\fP |
|
149 .fi |
|
150 .nf |
|
151 \f3Hello World\fP |
|
152 .fi |
|
153 .nf |
|
154 \f3js> 34 + 55\fP |
|
155 .fi |
|
156 .nf |
|
157 \f389\&.0\fP |
|
158 .fi |
|
159 .nf |
|
160 \f3js> t = new java\&.lang\&.Thread(function() { print(\&'Hello World\en\&'); })\fP |
|
161 .fi |
|
162 .nf |
|
163 \f3Thread[Thread\-0,5,main]\fP |
|
164 .fi |
|
165 .nf |
|
166 \f3js> t\&.start()\fP |
|
167 .fi |
|
168 .nf |
|
169 \f3js> Hello World\fP |
|
170 .fi |
|
171 .nf |
|
172 \f3\fP |
|
173 .fi |
|
174 .nf |
|
175 \f3js>\fP |
|
176 .fi |
|
177 .nf |
|
178 \f3\fP |
|
179 .fi |
|
180 .sp |
|
181 .SS RUN\ SCRIPT\ FILE\ WITH\ SCRIPT\ ARGUMENTS |
|
182 The test\&.js file is the script file\&. The \f3arg1\fR, \f3arg2\fR and \f3arg3\fR arguments are passed to the script\&. The script can access these arguments with an arguments array\&. |
|
183 .sp |
|
184 .nf |
|
185 \f3jrunscript test\&.js arg1 arg2 arg3\fP |
|
186 .fi |
|
187 .nf |
|
188 \f3\fP |
|
189 .fi |
|
190 .sp |
|
191 .SH SEE\ ALSO |
|
192 If JavaScript is used, then before it evaluates a user defined script, the \f3jrunscript\fR command initializes certain built-in functions and objects\&. These JavaScript built-ins are documented in JsDoc-Toolkit at http://code\&.google\&.com/p/jsdoc-toolkit/ |
47 .RE |
193 .RE |
48 |
194 .br |
49 .LP |
195 'pl 8.5i |
50 .SH "DESCRIPTION" |
196 'bp |
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 |
|
63 Specify where to find the user's .class files that are accessed by the script. |
|
64 .TP 3 |
|
65 \-cp path |
|
66 This is a synonym for \-classpath \f2path\fP |
|
67 .TP 3 |
|
68 \-Dname=value |
|
69 Set a Java system property. |
|
70 .TP 3 |
|
71 \-J<flag> |
|
72 Pass <flag> directly to the Java virtual machine on which jrunscript is run. |
|
73 .TP 3 |
|
74 \-l language |
|
75 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. |
|
76 .TP 3 |
|
77 \-e script |
|
78 Evaluate 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 |
|
81 Specify the character encoding used while reading script files. |
|
82 .TP 3 |
|
83 \-f script\-file |
|
84 Evaluate the given script file (batch mode). |
|
85 .TP 3 |
|
86 \-f \- |
|
87 Read and evaluate a script from standard input (interactive mode). |
|
88 .TP 3 |
|
89 \-help\ |
|
90 Output help message and exit. |
|
91 .TP 3 |
|
92 \-?\ |
|
93 Output help message and exit. |
|
94 .TP 3 |
|
95 \-q\ |
|
96 List all script engines available and exit. |
|
97 .RE |
|
98 |
|
99 .LP |
|
100 .SH "ARGUMENTS" |
|
101 .LP |
|
102 .LP |
|
103 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. |
|
104 .LP |
|
105 .SH "EXAMPLES" |
|
106 .LP |
|
107 .SS |
|
108 Executing inline scripts |
|
109 .LP |
|
110 .nf |
|
111 \f3 |
|
112 .fl |
|
113 jrunscript \-e "print('hello world')" |
|
114 .fl |
|
115 jrunscript \-e "cat('http://java.sun.com')" |
|
116 .fl |
|
117 \fP |
|
118 .fi |
|
119 |
|
120 .LP |
|
121 .SS |
|
122 Use specified language and evaluate given script file |
|
123 .LP |
|
124 .nf |
|
125 \f3 |
|
126 .fl |
|
127 jrunscript \-l js \-f test.js |
|
128 .fl |
|
129 \fP |
|
130 .fi |
|
131 |
|
132 .LP |
|
133 .SS |
|
134 Interactive mode |
|
135 .LP |
|
136 .nf |
|
137 \f3 |
|
138 .fl |
|
139 jrunscript |
|
140 .fl |
|
141 js> print('Hello World\\n'); |
|
142 .fl |
|
143 Hello World |
|
144 .fl |
|
145 js> 34 + 55 |
|
146 .fl |
|
147 89.0 |
|
148 .fl |
|
149 js> t = new java.lang.Thread(function() { print('Hello World\\n'); }) |
|
150 .fl |
|
151 Thread[Thread\-0,5,main] |
|
152 .fl |
|
153 js> t.start() |
|
154 .fl |
|
155 js> Hello World |
|
156 .fl |
|
157 |
|
158 .fl |
|
159 js> |
|
160 .fl |
|
161 \fP |
|
162 .fi |
|
163 |
|
164 .LP |
|
165 .SS |
|
166 Run script file with script arguments |
|
167 .LP |
|
168 .nf |
|
169 \f3 |
|
170 .fl |
|
171 jrunscript test.js arg1 arg2 arg3 |
|
172 .fl |
|
173 \fP |
|
174 .fi |
|
175 |
|
176 .LP |
|
177 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. |
|
178 .SH "SEE ALSO" |
|
179 .LP |
|
180 .LP |
|
181 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 |
|
182 .na |
|
183 \f2jsdocs\fP @ |
|
184 .fi |
|
185 http://download.oracle.com/javase/7/docs/technotes/tools/share/jsdocs/allclasses\-noframe.html. |
|
186 .LP |
|
187 |
|