ERA Command-line Console

The ERA Command-line console is a tool that allows you to execute tasks and manage clients directly from the command line, either by starting the ERA Command-line Console tool from the folder where ERA Console is located, or by typing eracmd.exe in the command prompt.

The ERA Command-line Console uses the ERA API to communicate with the ERA Server.

When you start the ERA Command-line Console, you will be asked to submit your login credentials. If you leave these parameters blank, default values will be used.

Note: The ERA Command-line console supports the autocomplete function. Start typing a command into the console and press TAB to complete the command. Pressing  TAB multiple times cycles through all available options. Pressing the UP/DOWN arrows cycles through the history of entered commands. Pressing ESC returns you to the previous text, pressing ESC twice erases the text completely.

 

Syntax from command-line:

eracmd.exe  --connectionparameters [command arguments [-commandflags]]  [;command arguments -commandflags]

Example:

eracmd.exe --s 127.0.0.1 version server -format csv
eracmd.exe --aa

Once started, the ERA command-line console automatically attempts to connect to the server. If the connection is successful, eracmd starts processing commands. If a command is not specified, eracmd starts in shell mode, where the user can write commands and see the result directly. To view a list of available commands, type the command HELP COMMANDS.

Syntax from shell mode:

[command arguments [-commandflags]]  [;command arguments -commandflags]

For arguments with white spaces, use quotes to contain all of the words as a single argument. To have a quotation mark inside of such argument, use double quotation mark. For example, "Say ""hello"" please" will be interpreted as 'Say "hello" please'

Two words connected to each other (one of them with quotation marks) will be connected. For example,  "Say "hello  will be interpreted as 'Say hello'

In the ERA command-line console, commands and keywords are not case sensitive. Only arguments used to query the database can be case sensitive.

@-replacing:

Any part of a command can be taken from a file. The file path should be surrounded by the @ symbol. When this syntax is used, the content of the specified file is used to take its place. If the file contains more lines, those lines are connected by commas and treated as a single line. This allows you to save to the file the argument list that will be used in next command. Empty lines are skipped. To suppress this functionality, the @ symbol must be surrounded by quotation marks.

Examples:

The file myconnection.txt contains the text '--s 192.168.0.1', and then the command eracmd.exe @myconnection@ to show clients id where name -like "*@*" will be used as eracmd.exe --s 192.168.0.1 show clients id where name -like *@*

This example creates a configuration task for clients with the word 'notebook' in their name:

show client id where client_name -like *Notebook* -out notebookID.txt -format csv -header none

task config c:\task_config_01.xml @notebookID.txt@

Commands:

Type HELP COMMANDS into the terminal to view a list of available commands, type HELP <command> to view instructions specific to a certain command. Commands can have mandatory parameters as well as optional parameters that you can specify using a keyword. Optional parameters called by a keyword can be used in any order after mandatory parameters are given. A command starts right after connection parameters, no prefix is needed. If no command is present in the command line, eracmd will start in shell mode. Multiple commands can be specified in one line, us a semicolon (;) to separate commands. To execute a script file containing multiple commands, use the command SCRIPT <scriptFileName>. In a script file, commands are separated by line breaks.

Command flags:

Command flags define the general behavior of a command, such as output format, or error handling. Command flags must be appended after a command and its arguments to function correctly. Place a dash (-) before each flag keyword to identify it. To see a list of flags, type the command HELP FLAGS.

Comments:

When in shell mode, comments can be used in scripts or in command line arguments. A comment begins with # and continues to the end of the current line. The command separator does not end a comment. If # is used in a quoted sequence, it does not start a comment and is used as a normal part of the quoted text instead.

Shell mode:

In shell mode, press TAB to activate context-sensitive autocomplete. Use the command HISTORY to enable, disable or clear command history. To choose a command from history, use the UP and DOWN arrows. To revert changes made by TAB or UP/DOWN, press ESC.

Startup script:

To have specific commands executed when shell mode is started, add them to the startup script.

The default startup script file is located in ProgramData (All Users\Application Data) in ESET\ESET Remote Administrator\Console\eracmd_startup.txt. An alternative path can be specified using the --startup eracmd.exe argument (for example, eracmd.exe --startup startup_script.txt).

The script is not executed as a separate subscript (using the "script" command), but it is executed as if the commands were typed directly into the console in shell mode (flags set in the startup script using the "set" command remain set in shell mode).

The "set save" command can be used to save current flag values to the startup script, overwriting the startup script file if it exists.

If an exit command is used in the startup script, commands following the exit command will not be executed, but eracmd.exe will not exit shell mode.

Formatting styles

Header and field flags can be used to specify formatting styles:

- keyword - constant texts are used (suitable for automatic post-processing)

- pretty - translatable texts are used (suitable for output for the user)

Header flag affects table headers (column names). Field flag affects table field values.

Connection parameters

Parameters pertaining to connection to the ERA server must be specified as command-line parameters. Eracmd.exe only processes commands if the connection is established successfully. All connection parameters use the double dash (--) prefix.

--s server:port: Server to connect to. Default value: localhost:2226

--u username:        Era server username. If the username starts with a domain prefix, it will be used as domain authentication username. This command cannot be used in combination with --ud or --uc. Default value: Administrator

--ud username: Domain authentication username. Cannot be used in combination with --u or --uc.

--uc: Use current Windows session credentials. Cannot be used in combination with --u or --ud.

--p password: Era server or domain authentication password. Cannot be used in combination with --pa. Default value: "" (blank password).

--pa: Prompts for password. After starting console, it will be possible to enter password displaying * only. Cannot be used in combination with --p.

 --aa: Ask for all the connection parameters. If specified, no other connection parameters can be specified.

--startup: Alternative startup script path. The startup script is automatically executed at the beginning of shell mode.