EJS(1) User Commands EJS(1) NAME ejs - Interpreted object-oriented scripting language (Javascript) shell. SYNOPSIS ejs [--class className] [--cmd literalScript] [--debug] [--lang [ecma|plus|fixed]] [--files "files..."] [--log logSpec] [--method methodName] [--nodebug] [--optimize level] [--searchPath ejsPath] [--standard] [--stats] [--strict] [--use 'module, ...'] [--version] [--warn level] file [arguments ...] DESCRIPTION The ejs command is an Ejscript command shell that can interpret and run JavaScript programs. Ejscript is an enhanced implementation of the JavaScript language for use in embedded applications such as web servers, embedded devices and mobile phones. It is especially well suited for Server-Side JavaScript web applications. INVOCATION The ejs command can be used as a shell to interactively interpret com- mands typed at the console or to run script files. When invoked with no files on the command line, ejs runs in interactive mode. In interac- tive mode, ejs reads input from the console and parses and executes script code as it is entered. In this mode, ejs command will read input until it has a complete block of code and will then execute the block. The last result value computed will be echoed to the console. For exam- ple: ejs-0> if (true) { ejs-2> print("Hello World"); ejs-2> } Hello World ejs-0> Note: the input prompt includes a level of nest indicator starting at zero and increasing upward as commands nest. This is a hint as to when you have closed sufficient braces for ejs to execute your command. As this is an internal compiler nest value, it will sometimes increment more than 1 for each brace. If ejs is invoked with a file name on the command line, that file will be read and its statements executed. One file may be supplied and the arguments after it will be passed into the script as command line argu- ments. For example: ejs myscript.es arg1 arg2 arg3 The given file may be either a script file or it may be a previously compiled Ejscript module with a .mod extension. If you require more script files to be parsed, use the --files "files ..." switch to supply extra scripts. These will be parsed in order, but after the primary script on the command line. The ejs command can also invoke a specific static method on startup. If either the --class or --method switches are supplied, then ejs will run the requested static method after the input file script statements have been executed. COMPLIANCE Ejscript is fully compliant with the JavaScript (ECMA-262 3.X) stan- dards, but it also offers a set of enhancements and fixes designed to improve the language and correct some longstanding JavaScript design issues. Use of these enhancements and fixes is optional and controlled via opt-in configuration switches and script pragmas. The ec compiler supports three language compliance modes: * ecma for strict ECMAScript compliance. * plus for close compliance plus compatible Ejscript enhancements. * fixed for close compliance, plus compatible Ejscript enhance- ments and breaking fixes. When Ejscript is built, the default compliance mode is defined. By default, this is plus mode. The fixed mode corrects several issues with Javascript that remain in the language due to browser compatibil- ity requirements. Ejscript, by targeting non-browser environments, can rectify these issues without impact to legacy applications. These changes are: * Assignments to non-existent properties inside functions, will create local variables rather than global variables. * Multiple declarations of the same variable in the same scope are not permitted. * The == and != operators will perform like their more rigorous conterparts === and !===. OPTIONS --class className Use the given className when searching for the startup method specified via --method or "main" by default. --cmd literalCommand Evaluate a literal command string. --debug Run in debug mode and generate symbolic stack backtraces if required. --files "files ..." Specifies an extra set of files to be compiled. The ejs command normally takes just one script file on the command line. The --files switch allows extra script to be compiled after the pri- mary script, but before the scripts are run. --log logName[:logLevel] Specify a file to log internal execution messages. Ejs will log execution related trace to the log file. The log level specifies the desired verbosity of output. Level 0 is the least verbose and level 9 is the most. Level 2 will include trace of each source statement and assembler instruction executed (provided --nodebug is not specifiec). --lang [ecma|plus|fixed] Set the language compliance mode. Use ecma for strict ECMAScript Edition 3 compliance. Use plus for close ECMAScript compliance plus Ejscript enhancements. Select fixed mode for ECMAScript features plus enhancements and some compatibility breaking fixes. ---method methodName Set the startup method name. Defaults to "main" if a --className is specified and --method is not. --nodebug Run the script without debug information. This will result in exceptions not having symbolic stack backtraces. --optimize level Set the code optimization level. Level values must be between 0 (least) and 9 (most). Default is 9. --searchPath ejsPath Override the module search path. The module search path is a set of directories that the ejs command will use when locating and loading Ejscript modules. Given a module named "a.b.c" in a script, ejs will use the following search strategy to locate the module: 1. Search for a module file named "a.b.c.mod" 2. Search for a module file named "a/b/c.mod" 3. Search for a module file named "a.b.c.mod" in EJSPATH 4. Search for a module file named c.mod in EJSPATH The search path is initially specified via the environment vari- able EJSPATH and may be overridden via the --searchPath ejsPath switch. EJSPATH and the ejsPath command line value are similar to the system PATH formats. On windows, path segments are sepa- rated by ";" and on Linux, Unix, FreeBSD and MAC, the path seg- ments are separated by ":" delimiters. --standard Run scripts in standard mode. Ejscript supports two parsing modes: strict and standard. Standard mode does not require vari- ables be declared and typed before use. --stats Print various statistics on exit. --strict Run scripts in standard mode. Ejscript supports two parsing modes: strict and standard. Strict mode requires that all vari- ables be declared and typed. --use 'module, ...' List of modules to preload before compiling input files. --warn level Set the compiler warning verbosity level. Level values must be between 0 (least verbose) and 9 (most). Default is 0. --version Print the ejs command version and exit. REPORTING BUGS Report bugs to dev@embedthis.com. COPYRIGHT Copyright (C) 2004-2009 Embedthis Software. Ejscript is a trademark of Embedthis Software. SEE ALSO ejsc, ejsgen, ejsmod, ejsvm ejs March 2009 EJS(1)