< prev index next >

src/java.scripting/share/man/jrunscript.1

Print this page


   1 '\" t
   2 .\" Copyright (c) 2006, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20 .\" or visit www.oracle.com if you need additional information or have any
  21 .\" questions.
  22 .\"
  23 .\"     Arch: generic
  24 .\"     Software: JDK 8
  25 .\"     Date: 21 November 2013
  26 .\"     SectDesc: Scripting Tools
  27 .\"     Title: jrunscript.1
  28 .\"
  29 .if n .pl 99999
  30 .TH jrunscript 1 "21 November 2013" "JDK 8" "Scripting Tools"
  31 .\" -----------------------------------------------------------------
  32 .\" * Define some portability stuff
  33 .\" -----------------------------------------------------------------
  34 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35 .\" http://bugs.debian.org/507673
  36 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  37 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38 .ie \n(.g .ds Aq \(aq
  39 .el       .ds Aq '
  40 .\" -----------------------------------------------------------------
  41 .\" * set default formatting
  42 .\" -----------------------------------------------------------------
  43 .\" disable hyphenation
  44 .nh
  45 .\" disable justification (adjust text to left margin only)
  46 .ad l
  47 .\" -----------------------------------------------------------------
  48 .\" * MAIN CONTENT STARTS HERE *
  49 .\" -----------------------------------------------------------------
  50 
  51 .SH NAME    
  52 jrunscript \- Runs a command-line script shell that supports interactive and batch modes\&. This command is experimental and unsupported\&.


  53 .SH SYNOPSIS    
  54 .sp     
  55 .nf     
  56 
  57 \fBjrunscript\fR [\fIoptions\fR] [\fIarguments\fR]
  58 .fi     
  59 .sp     
  60 .TP     
  61 \fIoptions\fR
  62 The command-line options\&. See Options\&.




  63 .TP     
  64 \fIarguments\fR
  65 Arguments, when used, follow immediately after options or the command name\&. See Arguments\&.




  66 .SH DESCRIPTION    
  67 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\&.
  68 .SH OPTIONS    














































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












 188 .fi     
 189 .sp     
 190 .SH SEE\ ALSO    
 191 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/
 192 .RE
 193 .br
 194 'pl 8.5i
 195 'bp



   1 .\" Copyright (c) 1994, 2019, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19 .\" or visit www.oracle.com if you need additional information or have any
  20 .\" questions.
  21 .\"
  22 .\" Automatically generated by Pandoc 2.3.1
  23 .\"
  24 .TH "JRUNSCRIPT" "1" "2018" "JDK 13" "JDK Commands"
  25 .hy
























  26 .SH NAME
  27 .PP
  28 jrunscript \- run a command\-line script shell that supports interactive
  29 and batch modes
  30 .SH SYNOPSIS
  31 .PP
  32 \f[B]Note:\f[R]
  33 .PP
  34 This tool is \f[B]experimental\f[R]\ and unsupported.
  35 .PP
  36 \f[CB]jrunscript\f[R] [\f[I]options\f[R]] [\f[I]arguments\f[R]]
  37 .TP
  38 .B \f[I]options\f[R]
  39 This represents the \f[CB]jrunscript\f[R] command\-line options that can
  40 be used.
  41 See \f[B]Options for the jrunscript Command\f[R].
  42 .RS
  43 .RE
  44 .TP
  45 .B \f[I]arguments\f[R]
  46 Arguments, when used, follow immediately after options or the command
  47 name.
  48 See \f[B]Arguments\f[R].
  49 .RS
  50 .RE
  51 .SH DESCRIPTION
  52 .PP
  53 The \f[CB]jrunscript\f[R] command is a language\-independent command\-line
  54 script shell.
  55 The \f[CB]jrunscript\f[R] command supports both an interactive
  56 (read\-eval\-print) mode and a batch (\f[CB]\-f\f[R] option) mode of
  57 script execution.
  58 By default, JavaScript is the language used, but the \f[CB]\-l\f[R] option
  59 can be used to specify a different language.
  60 By using Java to scripting language communication, the
  61 \f[CB]jrunscript\f[R] command supports an exploratory programming style.
  62 .PP
  63 If JavaScript is used, then before it evaluates a user defined script,
  64 the \f[CB]jrunscript\f[R] command initializes certain built\-in functions
  65 and objects, which are documented in the API Specification for
  66 \f[CB]jrunscript\f[R] JavaScript built\-in functions.
  67 .SH OPTIONS FOR THE JRUNSCRIPT COMMAND
  68 .TP
  69 .B \f[CB]\-cp\f[R] \f[I]path\f[R] or \f[CB]\-classpath\f[R] \f[I]path\f[R]
  70 Indicates where any class files are that the script needs to access.
  71 .RS
  72 .RE
  73 .TP
  74 .B \f[CB]\-D\f[R]\f[I]name\f[R]\f[CB]=\f[R]\f[I]value\f[R]
  75 Sets a Java system property.
  76 .RS
  77 .RE
  78 .TP
  79 .B \f[CB]\-J\f[R]\f[I]flag\f[R]
  80 Passes \f[I]flag\f[R] directly to the Java Virtual Machine where the
  81 \f[CB]jrunscript\f[R] command is running.
  82 .RS
  83 .RE
  84 .TP
  85 .B \f[CB]\-l\f[R] \f[I]language\f[R]
  86 Uses the specified scripting language.
  87 By default, JavaScript is used.
  88 To use other scripting languages, you must specify the corresponding
  89 script engine\[aq]s JAR file with the \f[CB]\-cp\f[R] or
  90 \f[CB]\-classpath\f[R] option.
  91 .RS
  92 .RE
  93 .TP
  94 .B \f[CB]\-e\f[R] \f[I]script\f[R]
  95 Evaluates the specified script.
  96 This option can be used to run one\-line scripts that are specified
  97 completely on the command line.
  98 .RS
  99 .RE
 100 .TP
 101 .B \f[CB]\-encoding\f[R] \f[I]encoding\f[R]
 102 Specifies the character encoding used to read script files.
 103 .RS
 104 .RE
 105 .TP
 106 .B \f[CB]\-f\f[R] \f[I]script\-file\f[R]
 107 Evaluates the specified script file (batch mode).
 108 .RS
 109 .RE
 110 .TP
 111 .B \f[CB]\-f\ \-\f[R]
 112 Enters interactive mode to read and evaluate a script from standard
 113 input.
 114 .RS
 115 .RE
 116 .TP
 117 .B \f[CB]\-help\f[R] or \f[CB]\-?\f[R]
 118 Displays a help message and exits.
 119 .RS
 120 .RE
 121 .TP
 122 .B \f[CB]\-q\f[R]
 123 Lists all script engines available and exits.
 124 .RS
 125 .RE






















 126 .SH ARGUMENTS
 127 .PP
 128 If arguments are present and if no \f[CB]\-e\f[R] or \f[CB]\-f\f[R] option
 129 is used, then the first argument is the script file and the rest of the
 130 arguments, if any, are passed as script arguments.
 131 If arguments and the \f[CB]\-e\f[R] or the \f[CB]\-f\f[R] option are used,
 132 then all arguments are passed as script arguments.
 133 If arguments \f[CB]\-e\f[R] and \f[CB]\-f\f[R] are missing, then the
 134 interactive mode is used.
 135 .SH EXAMPLE OF EXECUTING INLINE SCRIPTS
 136 .RS
 137 .PP
 138 \f[CB]jrunscript\ \-e\ "print(\[aq]hello\ world\[aq])"\f[R]
 139 .RE
 140 .RS
 141 .PP
 142 \f[CB]jrunscript\ \-e\ "cat(\[aq]http://www.example.com\[aq])"\f[R]
 143 .RE
 144 .SH EXAMPLE OF USING SPECIFIED LANGUAGE AND EVALUATE THE SCRIPT FILE
 145 .RS
 146 .PP
 147 \f[CB]jrunscript\ \-l\ js\ \-f\ test.js\f[R]
 148 .RE
 149 .SH EXAMPLE OF INTERACTIVE MODE
 150 .IP












































 151 .nf
 152 \f[CB]
 153 jrunscript
 154 js>\ print(\[aq]Hello\ World\\n\[aq]);
 155 Hello\ World
 156 js>\ 34\ +\ 55
 157 89.0
 158 js>\ t\ =\ new\ java.lang.Thread(function()\ {\ print(\[aq]Hello\ World\\n\[aq]);\ })
 159 Thread[Thread\-0,5,main]
 160 js>\ t.start()
 161 js>\ Hello\ World
 162 
 163 js>
 164 \f[R]
 165 .fi
 166 .SH RUN SCRIPT FILE WITH SCRIPT ARGUMENTS
 167 .PP
 168 In this example, the \f[CB]test.js\f[R] file is the script file.
 169 The \f[CB]arg1\f[R], \f[CB]arg2\f[R], and \f[CB]arg3\f[R] arguments are passed
 170 to the script.
 171 The script can access these arguments with an arguments array.
 172 .RS
 173 .PP
 174 \f[CB]jrunscript\ test.js\ arg1\ arg2\ arg3\f[R]
 175 .RE
< prev index next >