This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I know this is a really old topic: but maybe one way to address this problem is to have a general purpose tool that does a "pretty good" job of converting text-based output to structured output. | |
The reality is that most *nix tools output in a way that is designed for the human mind to "parse", so there is probably a detectable structure to the output that a smart tool [smarter than one I could create] could "guess" about a structure for the data and reformat it as json. The key is getting the data into "some sort of json output", even if imperfect. | |
For example, taking an output like this: | |
$ ifconfig | |
eth0 Link encap:Ethernet HWaddr 06:41:73:c2:ca:15 | |
inet addr:172.31.25.84 Bcast:172.31.31.255 Mask:255.255.240.0 | |
inet6 addr: fe80::441:73ff:fec2:ca15/64 Scope:Link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# note: you must set this to the path to your couchpotato base installation dir: | |
# export PYTHONPATH=./CouchPotatoServer | |
from CodernityDB.database import Database | |
import sys | |
import pprint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use DBI; | |
use Parallel::ForkManager; | |
# seqtest=# create sequence t1 increment by 1 start with 1 cache 1; | |
# CREATE SEQUENCE | |
# seqtest=# create sequence t1000 increment by 1 start with 1 cache 10000; | |
# CREATE SEQUENCE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use DBI; | |
use Parallel::ForkManager; | |
# create table t1a (id int4 auto_increment primary key) engine = innodb; | |
# create table t1b (id int4 auto_increment primary key) engine = myisam; | |
# run as "time ./mysql.pl t1a" or "time ./mysql.pl t1b" |