mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-07-13 01:20:24 +02:00
readme update
This commit is contained in:
233
README.md
233
README.md
@ -24,16 +24,21 @@ $ pip3 install jc
|
||||
```
|
||||
|
||||
## Usage
|
||||
```
|
||||
jc [parser] [options]
|
||||
```
|
||||
|
||||
`jc` accepts piped input from `STDIN` and outputs a JSON representation of the previous command's output to `STDOUT`. The JSON output can be compact or pretty formatted.
|
||||
|
||||
The first argument is required and identifies the command that is piping output to `jc` input. For example:
|
||||
Parsers:
|
||||
- `--ls` enables the `ls` parser
|
||||
- `--ifconfig` enables the `ifconfig` parser
|
||||
- `--netstat` enables the `netstat` parser
|
||||
- `--ps` enables the `ps` parser
|
||||
- `--route` enables the `route` parser
|
||||
|
||||
The second `-p` argument is optional and specifies whether to pretty format the JSON output.
|
||||
Options:
|
||||
- `-p` specifies whether to pretty format the JSON output
|
||||
|
||||
## Examples
|
||||
### ls
|
||||
@ -157,129 +162,115 @@ $ ifconfig | jc --ifconfig -p
|
||||
### netstat
|
||||
```
|
||||
$ netstat -p | jc --netstat -p
|
||||
{
|
||||
"client": {
|
||||
"tcp": {
|
||||
"ipv4": [
|
||||
{
|
||||
"local_address": "localhost.localdo",
|
||||
"local_port": "34480",
|
||||
"foreign_address": "lb-192-30-255-113",
|
||||
"foreign_port": "https",
|
||||
"state": "ESTABLISHED",
|
||||
"pid": 53550,
|
||||
"program_name": "git-remote-ht",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"local_address": "localhost.localdo",
|
||||
"local_port": "34478",
|
||||
"foreign_address": "lb-192-30-255-113",
|
||||
"foreign_port": "https",
|
||||
"state": "ESTABLISHED",
|
||||
"pid": 53550,
|
||||
"program_name": "git-remote-ht",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
[
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "localhost.localdo",
|
||||
"local_port": "34480",
|
||||
"foreign_address": "lb-192-30-255-113",
|
||||
"foreign_port": "https",
|
||||
"state": "ESTABLISHED",
|
||||
"pid": 53550,
|
||||
"program_name": "git-remote-ht",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "localhost.localdo",
|
||||
"local_port": "34478",
|
||||
"foreign_address": "lb-192-30-255-113",
|
||||
"foreign_port": "https",
|
||||
"state": "ESTABLISHED",
|
||||
"pid": 53550,
|
||||
"program_name": "git-remote-ht",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
```
|
||||
$ netstat -lp | jc --netstat -p
|
||||
{
|
||||
"server": {
|
||||
"tcp": {
|
||||
"ipv4": [
|
||||
{
|
||||
"local_address": "localhost",
|
||||
"local_port": "smtp",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 1594,
|
||||
"program_name": "master",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": "ssh",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 21918,
|
||||
"program_name": "sshd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
],
|
||||
"ipv6": [
|
||||
{
|
||||
"local_address": "localhost",
|
||||
"local_port": "smtp",
|
||||
"foreign_address": "[::]",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 1594,
|
||||
"program_name": "master",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"local_address": "[::]",
|
||||
"local_port": "ssh",
|
||||
"foreign_address": "[::]",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 21918,
|
||||
"program_name": "sshd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"udp": {
|
||||
"ipv4": [
|
||||
{
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": "bootpc",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"pid": 13903,
|
||||
"program_name": "dhclient",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"local_address": "localhost",
|
||||
"local_port": "323",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"pid": 30926,
|
||||
"program_name": "chronyd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
],
|
||||
"ipv6": [
|
||||
{
|
||||
"local_address": "localhost",
|
||||
"local_port": "323",
|
||||
"foreign_address": "[::]",
|
||||
"foreign_port": "*",
|
||||
"pid": 30926,
|
||||
"program_name": "chronyd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
$ netstat -lpn | jc --netstat -p
|
||||
[
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "127.0.0.1",
|
||||
"local_port": "42351",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 1112,
|
||||
"program_name": "containerd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "53",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 885,
|
||||
"program_name": "systemd-resolve",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "0.0.0.0",
|
||||
"local_port": "22",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 1127,
|
||||
"program_name": "sshd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "tcp",
|
||||
"network_protocol": "ipv6",
|
||||
"local_address": "::",
|
||||
"local_port": "22",
|
||||
"foreign_address": "::",
|
||||
"foreign_port": "*",
|
||||
"state": "LISTEN",
|
||||
"pid": 1127,
|
||||
"program_name": "sshd",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "udp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "127.0.0.53",
|
||||
"local_port": "53",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"pid": 885,
|
||||
"program_name": "systemd-resolve",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
},
|
||||
{
|
||||
"session_protocol": "udp",
|
||||
"network_protocol": "ipv4",
|
||||
"local_address": "192.168.71.131",
|
||||
"local_port": "68",
|
||||
"foreign_address": "0.0.0.0",
|
||||
"foreign_port": "*",
|
||||
"pid": 867,
|
||||
"program_name": "systemd-network",
|
||||
"receive_q": 0,
|
||||
"send_q": 0
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
### ps
|
||||
```
|
||||
|
Reference in New Issue
Block a user