[comment]: # ({e8144915-e8144915})
# 8 JS

[comment]: # ({/e8144915-e8144915})

[comment]: # ({bc11d563-b0613168})
#### Overview

zabbix\_js is a command line utility that can be used for embedded script testing.

This utility will execute a user script with a string parameter and print the result.
Scripts are executed using the embedded Zabbix scripting engine.

In case of compilation or execution errors zabbix\_js will print the error in stderr and exit with code 1.

[comment]: # ({/bc11d563-b0613168})

[comment]: # ({71240ff7-de3fe561})
#### Usage

```default
zabbix_js -s script-file -p input-param [-l log-level] [-t timeout]
zabbix_js -s script-file -i input-file [-l log-level] [-t timeout]
zabbix_js -h
zabbix_js -V
```

zabbix\_js accepts the following command line parameters:

```default
-s, --script script-file          Specify the file name of the script to execute. If "-" is specified as the file name, the script will be read from stdin.
-i, --input input-file            Specify the file name of the input information. The content will be passed to the script as a value. Mutually exclusive with -p. If "-" is specified as the file name, the script will be read from stdin.
-p, --param input-param           Specify the input parameter: the variable to be passed to the script as a value. Mutually exclusive with -i.
-l, --loglevel log-level          Specify the log level. Range: 0-5.
-t, --timeout timeout             Specify the timeout in seconds. Valid range: 1-600 seconds (default: 10 seconds).
-h, --help                        Display help information.
-V, --version                     Display the version number.
-w <webdriver url>                Enables browser monitoring.
```

#### Examples:

##### Example 1: Executing a script with a variable containing a value 

The script (`script-file.js`):

```default
return value;
```

Usage:

```default
zabbix_js -s script-file.js -p example_value
```

Output: `example_value`

##### Example 2: Executing a script with a file containing input information

The file with the script (`script-file.js`):

```default
return value;
```

The file with the input information (`example.txt`):

```default
Example of input information from the file
```

Usage:

```default
zabbix_js -s script-file.js -i example.txt
```

Output: `Example of input information from the file`

##### Example 3: Executing a script with input read from stdin

The file with the script (`script-file.js`):

```default
return value;
```

Usage:

```default
zabbix_js -s script-file.js -i -
```

Input (stdin):

```default
Example of input from stdin
```

Output: `Example of input from stdin`

[comment]: # ({/71240ff7-de3fe561})
