jrunscript.1 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. '\" t
  2. .\" Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
  3. .\" Arch: generic
  4. .\" Software: JDK 8
  5. .\" Date: 21 November 2013
  6. .\" SectDesc: Scripting Tools
  7. .\" Title: jrunscript.1
  8. .\"
  9. .if n .pl 99999
  10. .TH jrunscript 1 "21 November 2013" "JDK 8" "Scripting Tools"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH NAME
  31. jrunscript \- Runs a command-line script shell that supports interactive and batch modes\&. This command is experimental and unsupported\&.
  32. .SH SYNOPSIS
  33. .sp
  34. .nf
  35. \fBjrunscript\fR [\fIoptions\fR] [\fIarguments\fR]
  36. .fi
  37. .sp
  38. .TP
  39. \fIoptions\fR
  40. The command-line options\&. See Options\&.
  41. .TP
  42. \fIarguments\fR
  43. Arguments, when used, follow immediately after options or the command name\&. See Arguments\&.
  44. .SH DESCRIPTION
  45. 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\&.
  46. .SH OPTIONS
  47. .TP
  48. -classpath \fIpath\fR
  49. .br
  50. Indicate where any class files are that the script needs to access\&.
  51. .TP
  52. -cp \fIpath\fR
  53. .br
  54. Same as \f3-classpath\fR\f3path\fR\&.
  55. .TP
  56. -D\fIname\fR=\fIvalue\fR
  57. .br
  58. Sets a Java system property\&.
  59. .TP
  60. -J\fIflag\fR
  61. .br
  62. Passes \f3flag\fR directly to the Java Virtual Machine where the \f3jrunscript\fR command is running\&.
  63. .TP
  64. -I \fIlanguage\fR
  65. .br
  66. 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\&.
  67. .TP
  68. -e \fIscript\fR
  69. .br
  70. Evaluates the specified script\&. This option can be used to run one-line scripts that are specified completely on the command line\&.
  71. .TP
  72. -encoding \fIencoding\fR
  73. .br
  74. Specifies the character encoding used to read script files\&.
  75. .TP
  76. -f \fIscript-file\fR
  77. .br
  78. Evaluates the specified script file (batch mode)\&.
  79. .TP
  80. -f -
  81. .br
  82. Reads and evaluates a script from standard input (interactive mode)\&.
  83. .TP
  84. -help
  85. .br
  86. Displays a help message and exits\&.
  87. .TP
  88. -?
  89. .br
  90. Displays a help message and exits\&.
  91. .TP
  92. -q
  93. .br
  94. Lists all script engines available and exits\&.
  95. .SH ARGUMENTS
  96. 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\&.
  97. .SH EXAMPLES
  98. .SS EXECUTE\ INLINE\ SCRIPTS
  99. .sp
  100. .nf
  101. \f3jrunscript \-e "print(\&'hello world\&')"\fP
  102. .fi
  103. .nf
  104. \f3jrunscript \-e "cat(\&'http://www\&.example\&.com\&')"\fP
  105. .fi
  106. .nf
  107. \f3\fP
  108. .fi
  109. .sp
  110. .SS USE\ SPECIFIED\ LANGUAGE\ AND\ EVALUATE\ THE\ SCRIPT\ FILE
  111. .sp
  112. .nf
  113. \f3jrunscript \-l js \-f test\&.js\fP
  114. .fi
  115. .nf
  116. \f3\fP
  117. .fi
  118. .sp
  119. .SS INTERACTIVE\ MODE
  120. .sp
  121. .nf
  122. \f3jrunscript\fP
  123. .fi
  124. .nf
  125. \f3js> print(\&'Hello World\en\&');\fP
  126. .fi
  127. .nf
  128. \f3Hello World\fP
  129. .fi
  130. .nf
  131. \f3js> 34 + 55\fP
  132. .fi
  133. .nf
  134. \f389\&.0\fP
  135. .fi
  136. .nf
  137. \f3js> t = new java\&.lang\&.Thread(function() { print(\&'Hello World\en\&'); })\fP
  138. .fi
  139. .nf
  140. \f3Thread[Thread\-0,5,main]\fP
  141. .fi
  142. .nf
  143. \f3js> t\&.start()\fP
  144. .fi
  145. .nf
  146. \f3js> Hello World\fP
  147. .fi
  148. .nf
  149. \f3\fP
  150. .fi
  151. .nf
  152. \f3js>\fP
  153. .fi
  154. .nf
  155. \f3\fP
  156. .fi
  157. .sp
  158. .SS RUN\ SCRIPT\ FILE\ WITH\ SCRIPT\ ARGUMENTS
  159. 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\&.
  160. .sp
  161. .nf
  162. \f3jrunscript test\&.js arg1 arg2 arg3\fP
  163. .fi
  164. .nf
  165. \f3\fP
  166. .fi
  167. .sp
  168. .SH SEE\ ALSO
  169. 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/
  170. .RE
  171. .br
  172. 'pl 8.5i
  173. 'bp