Java Reference
In-Depth Information
Global Functions
The
jrunscript
command-line shell makes several global functions available for use as
listed in Table
9-3
.
Table 9-3.
The List of Global Objects Loaded by the jrunscript Command-Line Shell
Function
Description
cat(path, pattern)
Shows the content of a file, URL, or InputStream specified
by
path
. Optionally, you can specify
pattern
to show only
the matching contents.
cd(target)
Changes the present working directory to the
target
directory.
cp(from, to)
Copies a file, URL, or stream to another file or stream.
date()
Prints the current date using the current locale.
del(pathname)
A synonym for the
rm
command.
dir(d, filter)
A synonym for the
ls
command.
dirname(pathname)
Returns the directory part of the specified
pathname
.
echo(str)
Echoes the specified string arguments.
exec(cmd)
Starts a child process, executes the specified command,
waits for completion, and returns the exit code.
exit(code)
Exit the shell program with the specified
code
as the
exit code.
find(dir, pattern,
callback)
Find files in
dir
with file names matching the specified
pattern
. When a match is found, the
callback
function
is called passing the found file. Search is performed
recursively in all subdirectories. You can pass some
functions listed in this table as
callback
. If
callback
is not
specified, the default is to print the found files path.
If
pattern
is not specified, all files are printed.
grep(pattern, files)
Unix-like
grep
, but accepts JavaScript regex patterns.
ip(name)
Prints the IP addresses of a given domain name.
load(path)
Loads and evaluates JavaScript code from a stream, file,
or URL.
ls(dir, filter)
Lists the files in
dir
matching the
filter
regular
expression.
mkdir(dir)
Creates a new directory with the name
dir
.
(
continued
)
Search WWH ::
Custom Search