Java Reference
In-Depth Information
FP_NO_HOST_CHECK
USERDOMAIN
LOGONSERVER
PROMPT
OS
...
The following script uses the $EXEC() global function to list all files with the
extension txt , which contains the ksharan :
jjs> $EXEC("grep -l ksharan *.txt");
test.txt
You can capture the output of the shell command in a variable. Scripting mode allows
for expression substitution in strings enclosed in double quotes. Notice that the expression
substitution feature is not available in strings enclosed in single quotes. The expression
is specified as ${expression} . The following commands capture the value of the date
shell command in a variable and embed the date value in a string using the expression
substitution. Notice that in the example the expression substitution does not work when
the string is enclosed in single quotes:
c:\ >jjs -scripting
jjs> var today = `date`
jjs> "Today is ${today}"
Today is Mon Jul 14 22:48:26 CDT 2014
jjs> 'Today is ${today}'
Today is ${today}
jjs> quit()
c:\>
You can also execute the shell script stored in a file using the scripting mode:
C:\> jjs -scripting myscript.js
The jjs tool supports heredocs in script files that can be run in scripting mode.
A heredoc is also known as a here document , here-string , or here-script . It is a multiline
string in which whitespaces are preserved. A heredoc starts with a double angle bracket
(<<) and a delimiting identifier. Typically, EOF or END is used as the delimiting identifier.
However, you can use any other identifier that is not used as an identifier elsewhere in the
script. The multiline string starts at the end line. The string ends with the same delimiting
identifier. The following is an example of using a heredoc in Nashorn:
var str = <<EOF
This is a multi-line string using the heredoc syntax.
Bye Heredoc!
EOF
 
Search WWH ::




Custom Search