jrunscript.1 6.3 KB
Newer Older
R
rgallard 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
'\" t
.\"  Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
.\"
.\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
.\"
.\" This code is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License version 2 only, as
.\" published by the Free Software Foundation.
.\"
.\" This code is distributed in the hope that it will be useful, but WITHOUT
.\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
.\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
.\" version 2 for more details (a copy is included in the LICENSE file that
.\" accompanied this code).
.\"
.\" You should have received a copy of the GNU General Public License version
.\" 2 along with this work; if not, write to the Free Software Foundation,
.\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
.\"
.\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
.\" or visit www.oracle.com if you need additional information or have any
.\" questions.
.\"
.\"     Arch: generic
.\"     Software: JDK 8
.\"     Date: 21 November 2013
.\"     SectDesc: Scripting Tools
.\"     Title: jrunscript.1
.\"
.if n .pl 99999
.TH jrunscript 1 "21 November 2013" "JDK 8" "Scripting Tools"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
D
duke 已提交
51

R
rgallard 已提交
52 53 54 55 56
.SH NAME    
jrunscript \- Runs a command-line script shell that supports interactive and batch modes\&. This command is experimental and unsupported\&.
.SH SYNOPSIS    
.sp     
.nf     
D
duke 已提交
57

R
rgallard 已提交
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
\fBjrunscript\fR [\fIoptions\fR] [\fIarguments\fR]
.fi     
.sp     
.TP     
\fIoptions\fR
The command-line options\&. See Options\&.
.TP     
\fIarguments\fR
Arguments, when used, follow immediately after options or the command name\&. See Arguments\&.
.SH DESCRIPTION    
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\&.
.SH OPTIONS    
.TP
-classpath \fIpath\fR
.br
Indicate where any class files are that the script needs to access\&.
.TP
-cp \fIpath\fR
.br
Same as \f3-classpath\fR\f3path\fR\&.
.TP
-D\fIname\fR=\fIvalue\fR
.br
Sets a Java system property\&.
.TP
-J\fIflag\fR
.br
Passes \f3flag\fR directly to the Java Virtual Machine where the \f3jrunscript\fR command is running\&.
.TP
-I \fIlanguage\fR
.br
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\&.
.TP
-e \fIscript\fR
.br
Evaluates the specified script\&. This option can be used to run one-line scripts that are specified completely on the command line\&.
.TP
-encoding \fIencoding\fR
.br
Specifies the character encoding used to read script files\&.
.TP
-f \fIscript-file\fR
.br
Evaluates the specified script file (batch mode)\&.
.TP
-f -
.br
Reads and evaluates a script from standard input (interactive mode)\&.
.TP
-help
.br
Displays a help message and exits\&.
.TP
-?
.br
Displays a help message and exits\&.
.TP
-q
.br
Lists all script engines available and exits\&.
.SH ARGUMENTS    
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\&.
.SH EXAMPLES    
.SS EXECUTE\ INLINE\ SCRIPTS    
.sp     
.nf     
\f3jrunscript \-e "print(\&'hello world\&')"\fP
.fi     
.nf     
\f3jrunscript \-e "cat(\&'http://www\&.example\&.com\&')"\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SS USE\ SPECIFIED\ LANGUAGE\ AND\ EVALUATE\ THE\ SCRIPT\ FILE    
.sp     
.nf     
\f3jrunscript \-l js \-f test\&.js\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SS INTERACTIVE\ MODE    
.sp     
.nf     
\f3jrunscript\fP
.fi     
.nf     
\f3js> print(\&'Hello World\en\&');\fP
.fi     
.nf     
\f3Hello World\fP
.fi     
.nf     
\f3js> 34 + 55\fP
.fi     
.nf     
\f389\&.0\fP
.fi     
.nf     
\f3js> t = new java\&.lang\&.Thread(function() { print(\&'Hello World\en\&'); })\fP
.fi     
.nf     
\f3Thread[Thread\-0,5,main]\fP
.fi     
.nf     
\f3js> t\&.start()\fP
.fi     
.nf     
\f3js> Hello World\fP
.fi     
.nf     
\f3\fP
.fi     
.nf     
\f3js>\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SS RUN\ SCRIPT\ FILE\ WITH\ SCRIPT\ ARGUMENTS    
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\&.
.sp     
.nf     
\f3jrunscript test\&.js arg1 arg2 arg3\fP
.fi     
.nf     
\f3\fP
.fi     
.sp     
.SH SEE\ ALSO    
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/
.RE
.br
'pl 8.5i
'bp