Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nginx
GitHub Repository: nginx/nginx.org
Path: blob/main/xml/en/docs/njs/cli.xml
1 views
1
<?xml version="1.0"?>
2
3
<!--
4
Copyright (C) Nginx, Inc.
5
-->
6
7
<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">
8
9
<article name="Command-line interface"
10
link="/en/docs/njs/cli.html"
11
lang="en"
12
rev="4">
13
14
<section>
15
<para>
16
njs scripts development and debugging can be performed
17
from the command-line.
18
The command-line utility is available after the installation of
19
the Linux <link doc="install.xml" id="install_package">package</link>
20
or after building from the
21
<link doc="install.xml" id="install_sources">sources</link>.
22
Compared to njs running inside nginx,
23
nginx objects
24
(<link doc="reference.xml" id="http">HTTP</link> and
25
<link doc="reference.xml" id="stream">Stream</link>)
26
are not available in the utility.
27
<example>
28
$ echo "2**3" | njs -q
29
8
30
31
$ njs
32
>> globalThis
33
global {
34
njs: njs {
35
version: '0.3.9'
36
},
37
global: [Circular],
38
process: process {
39
argv: [
40
'/usr/bin/njs'
41
],
42
env: {
43
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
44
HOSTNAME: 'f777c149d4f8',
45
TERM: 'xterm',
46
NGINX_VERSION: '1.17.9',
47
NJS_VERSION: '0.3.9',
48
PKG_RELEASE: '1~buster',
49
HOME: '/root'
50
}
51
},
52
console: {
53
log: [Function: native],
54
dump: [Function: native],
55
time: [Function: native],
56
timeEnd: [Function: native]
57
},
58
print: [Function: native]
59
}
60
>>
61
</example>
62
</para>
63
64
</section>
65
66
</article>
67
68