Java Reference
In-Depth Information
Table 10-2. Global Objects and Functions Available in Scripting Mode
Global Object
Description
$ARG
Stores the arguments passed to the script. Works the same
way as arguments .
$ENV
Maps all environment variables to an object.
$EXEC(cmd, input)
A global function used to run a command in a new process
passing input to cmd . Both arguments can be commands, and
in that case, the output of input will be passed as input Io cmd .
$OUT
Stores the latest standard output of the process. For example,
the result of executing the $EXEC() is saved in $OUT .
$ERR
Stores the latest standard output of the process.
$EXIT
Stores the exit code of the process. A nonzero value indicates
that the process failed.
echo(arg1, arg2,...) The echo() function works the same as the print() function,
but it is available only in scripting mode.
readLine(prompt)
Reads one line of input from standard input. The specified
argument is displayed as a prompt. By default, the read input
is displayed on the standard output. The function returns the
read input.
readFully(filePath)
Reads the entire contents of the specified file. The contents
are displayed on the standard output by default. You can
assign the returned value of the function to a variable.
The following script shows how to use the $ARG global object:
c:\>jjs -scripting -- 10 20 30
jjs> for each(var arg in $ARG) print(arg);
10
20
30
jjs>
The following script shows how to use the $ENV global object. It prints the value of
the OS environment variable on Windows, and lists all environment variables:
jjs> print($ENV.OS);
Windows_NT
jjs> for(var x in $ENV) print(x);
LOCALAPPDATA
PROCESSOR_LEVEL
 
 
Search WWH ::




Custom Search