2.4 KiB
jc.parsers.shadow
jc - JSON CLI output utility /etc/shadow
file parser
Usage (cli):
$ sudo cat /etc/shadow | jc --shadow
Usage (module):
import jc result = jc.parse('shadow', shadow_file_output)
or
import jc.parsers.shadow result = jc.parsers.shadow.parse(shadow_file_output)
Schema:
[ { "username": string, "password": string, "last_changed": integer, "minimum": integer, "maximum": integer, "warn": integer, "inactive": integer, "expire": integer } ]
Examples:
$ sudo cat /etc/shadow | jc --shadow -p [ {
-
"username"
- "root", -
"password"
- "*", -
"last_changed"
- 18113, -
"minimum"
- 0, -
"maximum"
- 99999, -
"warn"
- 7, -
"inactive"
- null, -
"expire"
- null }, { -
"username"
- "daemon", -
"password"
- "*", -
"last_changed"
- 18113, -
"minimum"
- 0, -
"maximum"
- 99999, -
"warn"
- 7, -
"inactive"
- null, -
"expire"
- null }, { -
"username"
- "bin", -
"password"
- "*", -
"last_changed"
- 18113, -
"minimum"
- 0, -
"maximum"
- 99999, -
"warn"
- 7, -
"inactive"
- null, -
"expire"
- null }, ... ]$ sudo cat /etc/shadow | jc --shadow -p -r [ {
-
"username"
- "root", -
"password"
- "*", -
"last_changed"
- "18113", -
"minimum"
- "0", -
"maximum"
- "99999", -
"warn"
- "7", -
"inactive"
- "", -
"expire"
- "" }, { -
"username"
- "daemon", -
"password"
- "*", -
"last_changed"
- "18113", -
"minimum"
- "0", -
"maximum"
- "99999", -
"warn"
- "7", -
"inactive"
- "", -
"expire"
- "" }, { -
"username"
- "bin", -
"password"
- "*", -
"last_changed"
- "18113", -
"minimum"
- "0", -
"maximum"
- "99999", -
"warn"
- "7", -
"inactive"
- "", -
"expire"
- "" }, ... ]
info Objects
class info()
Provides parser metadata (version, author, etc.)
parse
def parse(data, raw=False, quiet=False)
Main text parsing function
Arguments:
data
- (string) text data to parseraw
- (boolean) unprocessed output if Truequiet
- (boolean) suppress warning messages if True
Returns:
List of Dictionaries. Raw or processed structured data.
Parser Information
Compatibility: linux, darwin, aix, freebsd
Version 1.4 by Kelly Brazil (kellyjonbrazil@gmail.com)