2
|
1 |
." Copyright 2006 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
19 |
." CA 95054 USA or visit www.sun.com if you need additional information or
|
|
20 |
." have any questions.
|
2692
|
21 |
."
|
|
22 |
.TH jrunscript 1 "04 May 2009"
|
|
23 |
." Generated from HTML by html2man (author: Eric Armstrong)
|
2
|
24 |
|
|
25 |
.LP
|
2692
|
26 |
.SH "Name"
|
2
|
27 |
jrunscript \- command line script shell
|
|
28 |
.LP
|
|
29 |
.SH "SYNOPSIS"
|
|
30 |
.LP
|
|
31 |
|
|
32 |
.LP
|
|
33 |
.nf
|
|
34 |
\f3
|
|
35 |
.fl
|
|
36 |
\fP\f3jrunscript\fP [ \f2options\fP ] [ arguments... ]
|
|
37 |
.fl
|
|
38 |
.fi
|
|
39 |
|
|
40 |
.LP
|
|
41 |
.SH "PARAMETERS"
|
|
42 |
.LP
|
|
43 |
|
|
44 |
.LP
|
2692
|
45 |
.RS 3
|
2
|
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.
|
2692
|
52 |
.RE
|
|
53 |
|
2
|
54 |
.LP
|
|
55 |
.SH "DESCRIPTION"
|
|
56 |
.LP
|
|
57 |
|
|
58 |
.LP
|
|
59 |
.LP
|
|
60 |
\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.
|
|
61 |
.LP
|
|
62 |
.LP
|
|
63 |
\f3NOTE:\fP This tool is \f3experimental\fP and may \f3not\fP be available in future versions of the JDK.
|
|
64 |
.LP
|
|
65 |
.SH "OPTIONS"
|
|
66 |
.LP
|
|
67 |
|
|
68 |
.LP
|
2692
|
69 |
.RS 3
|
2
|
70 |
.TP 3
|
|
71 |
\-classpath path
|
|
72 |
Specify where to find the user's .class files that are accessed by the script.
|
|
73 |
.TP 3
|
|
74 |
\-cp path
|
|
75 |
This is a synonym for \-classpath \f2path\fP
|
|
76 |
.TP 3
|
|
77 |
\-Dname=value
|
|
78 |
Set a Java system property.
|
|
79 |
.TP 3
|
|
80 |
\-J<flag>
|
|
81 |
Pass <flag> directly to the Java virtual machine on which jrunscript is run.
|
|
82 |
.TP 3
|
|
83 |
\-l language
|
|
84 |
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.
|
|
85 |
.TP 3
|
|
86 |
\-e script
|
|
87 |
Evaluate the given script. This option can be used to run "one liner" scripts specified completely on the command line.
|
|
88 |
.TP 3
|
|
89 |
\-encoding encoding
|
|
90 |
Specify the character encoding used while reading script files.
|
|
91 |
.TP 3
|
|
92 |
\-f script\-file
|
|
93 |
Evaluate the given script file (batch mode).
|
|
94 |
.TP 3
|
|
95 |
\-f \-
|
|
96 |
Read and evaluate a script from standard input (interactive mode).
|
|
97 |
.TP 3
|
|
98 |
\-help\
|
|
99 |
Output help message and exit.
|
|
100 |
.TP 3
|
|
101 |
\-?\
|
|
102 |
Output help message and exit.
|
|
103 |
.TP 3
|
|
104 |
\-q\
|
|
105 |
List all script engines available and exit.
|
2692
|
106 |
.RE
|
|
107 |
|
2
|
108 |
.LP
|
|
109 |
.SH "ARGUMENTS"
|
|
110 |
.LP
|
|
111 |
.LP
|
|
112 |
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.
|
|
113 |
.LP
|
|
114 |
.SH "EXAMPLES"
|
|
115 |
.LP
|
|
116 |
\f3Executing inline scripts\fP
|
|
117 |
.LP
|
|
118 |
.RS 3
|
|
119 |
|
|
120 |
.LP
|
|
121 |
.nf
|
|
122 |
\f3
|
|
123 |
.fl
|
|
124 |
jrunscript \-e "print('hello world')"
|
|
125 |
.fl
|
|
126 |
jrunscript \-e "cat('http://java.sun.com')"
|
|
127 |
.fl
|
|
128 |
\fP
|
|
129 |
.fi
|
|
130 |
.RE
|
|
131 |
|
|
132 |
.LP
|
|
133 |
\f3Use specified language and evaluate given script file\fP
|
|
134 |
.LP
|
|
135 |
.RS 3
|
|
136 |
|
|
137 |
.LP
|
|
138 |
.nf
|
|
139 |
\f3
|
|
140 |
.fl
|
|
141 |
jrunscript \-l js \-f test.js
|
|
142 |
.fl
|
|
143 |
\fP
|
|
144 |
.fi
|
|
145 |
.RE
|
|
146 |
|
|
147 |
.LP
|
|
148 |
\f3Interactive mode\fP
|
|
149 |
.LP
|
|
150 |
.RS 3
|
|
151 |
|
|
152 |
.LP
|
|
153 |
.nf
|
|
154 |
\f3
|
|
155 |
.fl
|
|
156 |
jrunscript
|
|
157 |
.fl
|
|
158 |
js>print('hello world');
|
|
159 |
.fl
|
|
160 |
hello world
|
|
161 |
.fl
|
|
162 |
js>34 + 55
|
|
163 |
.fl
|
|
164 |
89
|
|
165 |
.fl
|
|
166 |
js> thread(function() { print('hello world'); }
|
|
167 |
.fl
|
|
168 |
hello world
|
|
169 |
.fl
|
|
170 |
js>
|
|
171 |
.fl
|
|
172 |
\fP
|
|
173 |
.fi
|
|
174 |
.RE
|
|
175 |
|
|
176 |
.LP
|
|
177 |
\f3Run script file with script arguments\fP
|
|
178 |
.LP
|
|
179 |
.RS 3
|
|
180 |
|
|
181 |
.LP
|
|
182 |
.nf
|
|
183 |
\f3
|
|
184 |
.fl
|
|
185 |
jrunscript test.js arg1 arg2 arg3
|
|
186 |
.fl
|
|
187 |
\fP
|
|
188 |
.fi
|
|
189 |
.RE
|
|
190 |
|
|
191 |
.LP
|
|
192 |
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.
|
|
193 |
.SH "SEE ALSO"
|
|
194 |
.LP
|
|
195 |
.LP
|
|
196 |
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.
|
|
197 |
.LP
|
|
198 |
|
|
199 |
.LP
|
|
200 |
|