blob: 5abd126385301b3968843be957b12cba72fc69f2 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001." 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.
tbell16c34dd2009-05-04 18:28:26 -070021."
22.TH jrunscript 1 "04 May 2009"
23." Generated from HTML by html2man (author: Eric Armstrong)
duke6e45e102007-12-01 00:00:00 +000024
25.LP
tbell16c34dd2009-05-04 18:28:26 -070026.SH "Name"
duke6e45e102007-12-01 00:00:00 +000027jrunscript \- 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
tbell16c34dd2009-05-04 18:28:26 -070045.RS 3
duke6e45e102007-12-01 00:00:00 +000046.TP 3
47options
48Options, if used, should follow immediately after the command name.
49.TP 3
50arguments
51Arguments, if used, should follow immediately after options or command name.
tbell16c34dd2009-05-04 18:28:26 -070052.RE
53
duke6e45e102007-12-01 00:00:00 +000054.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
tbell16c34dd2009-05-04 18:28:26 -070069.RS 3
duke6e45e102007-12-01 00:00:00 +000070.TP 3
71\-classpath path
72Specify where to find the user's .class files that are accessed by the script.
73.TP 3
74\-cp path
75This is a synonym for \-classpath \f2path\fP
76.TP 3
77\-Dname=value
78Set a Java system property.
79.TP 3
80\-J<flag>
81Pass <flag> directly to the Java virtual machine on which jrunscript is run.
82.TP 3
83\-l language
84Use 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
87Evaluate 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
90Specify the character encoding used while reading script files.
91.TP 3
92\-f script\-file
93Evaluate the given script file (batch mode).
94.TP 3
95\-f \-
96Read and evaluate a script from standard input (interactive mode).
97.TP 3
98\-help\
99Output help message and exit.
100.TP 3
101\-?\
102Output help message and exit.
103.TP 3
104\-q\
105List all script engines available and exit.
tbell16c34dd2009-05-04 18:28:26 -0700106.RE
107
duke6e45e102007-12-01 00:00:00 +0000108.LP
109.SH "ARGUMENTS"
110.LP
111.LP
112If [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
124jrunscript \-e "print('hello world')"
125.fl
126jrunscript \-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
141jrunscript \-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
156jrunscript
157.fl
158js>print('hello world');
159.fl
160hello world
161.fl
162js>34 + 55
163.fl
16489
165.fl
166js> thread(function() { print('hello world'); }
167.fl
168hello world
169.fl
170js>
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
185jrunscript test.js arg1 arg2 arg3
186.fl
187\fP
188.fi
189.RE
190
191.LP
192test.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
196If 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