
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
generic-stdout-parser
Advanced tools
Parse any type of command line/cmd/shell stdout into Javascrpt Object, JSON or XML
Unable to find a parser for results of command 'v4l2-ctl --list-ctrls', I had to create it myself. Soooo fed up of manually creating parsers for cmd/sh/bash command line output logs , I created this NPM package to centralize all my homemade parsers at the same place, and possibly avoid to have to specify the input format
When there are useless lines added to a stdout json or xml shell output, the parser manages to detect and ignore them.
To avoid duplication with linux tables parsing of package node-shell-parser, it is possible to use 'node-shell-parser' as inputFormat
Available input formats are
Available output formats are
npm install generic-stdout-parser
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = [' some useless output line',' <lelama>NUL</lelama> ',' another useless output line']
const parseRes = new StdOutParser(stdoutlog).parse()
console.log(parseRes.result.lelama === "NUL")
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['{ "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['blablablabla',' { "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = '<lelama>NUL</lelama>'
const parseRes = new StdOutParser(stdoutlog).parse()
assert(parseRes.result.lelama === "NUL",'lelama property not found in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ['{ "lelama": "NUL" }']
const parseRes = new StdOutParser(stdoutlog,{'resultFormat': 'xml'}).parse()
console.log(parseRes)
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = `User Controls
brightness (int) : min=0 max=100 step=1 default=50 value=50 flags=slider
contrast (int) : min=-100 max=100 step=1 default=0 value=-10 flags=slider
saturation (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
red_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
blue_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
horizontal_flip (bool) : default=0 value=0
Codec Controls
video_bitrate_mode (menu) : min=0 max=1 default=0 value=0 flags=update
video_bitrate (int) : min=25000 max=25000000 step=25000 default=10000000 value=10000000
repeat_sequence_header (bool) : default=0 value=0
h264_i_frame_period (int) : min=0 max=2147483647 step=1 default=60 value=60
h264_level (menu) : min=0 max=11 default=11 value=11
h264_profile (menu) : min=0 max=4 default=4 value=4` ;
const parseRes = new StdOutParser(stdoutlog,{inputFormat: 'raw_structure_datatype_props'}).parse()
assert(parseRes.result.find(x => x.name === 'User Controls').properties
.find(x => x.name === 'brightness').properties
.find(x => x.name === 'value')
.value === '50',
'Unable to find Camera Controls auto_exposure.max with value 3 in '+JSON.stringify(parseRes))
const StdOutParser = require('generic-stdout-parser')
const stdoutlog = ` PID TTY TIME CMD
23856 pts/1 00:00:00 ps
31475 pts/1 00:00:00 bash
` ;
const parseRes = new StdOutParser(stdoutlog,{'inputFormat': 'shell'}).parse()
assert(parseRes.result[0]['TTY'] === '23856 pts/1','Unable to find TTY = N23856 pts/1 in '+parseRes)
Don't hesitate to contribute with GitHub pull requests !
FAQs
Parse any type of command line/cmd/shell stdout into Javascrpt Object, JSON or XML
The npm package generic-stdout-parser receives a total of 188 weekly downloads. As such, generic-stdout-parser popularity was classified as not popular.
We found that generic-stdout-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.