Ifconfig / Convert Command Output To Json Via Pipe
Convert Command Output To Json Via Pipe
Easily convert the output of the ifconfig command to JSON format for automation and integration.
$
Terminal <ifconfig> | jc <--ifconfig> <ifconfig> | jc <--ifconfig> #!/bin/bash
# Convert Command Output To Json Via Pipe
{{ifconfig}} | jc {{--ifconfig}} When To Use
Integrating network configurations into an automated pipeline for processing.
Command Builder
Tune the command before you copy it
$
Generated Command <ifconfig> | jc <--ifconfig> Terminal Output
Expected runtime feedback
>
Output {
"eth0": {
"inet": "192.168.1.10",
"netmask": "255.255.255.0"
},
"lo": {
"inet": "127.0.0.1",
"netmask": "255.0.0.0"
}
} Command Breakdown
What each part is doing
-
<ifconfig> - Base Command
- The executable that performs this operation. Here it runs Ifconfig before the shell applies any redirect operators.
-
<ifconfig> - ifconfig
- The value supplied for ifconfig.
-
<--ifconfig> - ifconfig
- The value supplied for ifconfig.
How To Run
Execution path
- Step 1
Run the ifconfig command to display network configurations.
- Step 2
Pipe the output to jc with the --ifconfig option to convert it to JSON.
- Step 3
Review the JSON output for integration into your automated pipeline.
Alternative Approaches
Comparable commands in other tools
Alternative networking tools for the same job.
Jc / Convert Command Output To Json Via Magic Syntax
jc <ifconfig> Wget / Download Web Page With Resources wget -pkw 3 {https://example.com/some_page.html} Invoke Webrequest / Pass Username Password For Authentication Invoke-WebRequest -Headers @{ Authorization = "Basic "+ [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("myusername:mypassword")) } {http://example.com} Invoke Webrequest / Send Form Encoded Data Post Request Invoke-WebRequest -Method Post -Body @{ name='bob' } {http://example.com/form} Dnsmasq / Display Dnsmasq Version dnsmasq --version