2 ms·
That said, that might not be the best example, because that same first command with Unix utilities is just: pgrep -f /bin/bash
by skykooler 8y ago
That said, that might not be the best example, because that same first command with Unix utilities is just:
pgrep -f /bin/bash
- geophile 8y agoOK, how about this: osh timer 1 ^ \ f 't: (t, processes())' ^ \ expand 1 ^ f 't, p: (p.pid, int(t), p.commandline)' ^ sql "insert into process values(%s, %s, %s)" - timer 1: Generate a timestamp every second. - f 't: (t, processes())': Take the timestamp as input and generate a timestamp and sequence of Process objects. - expand 1: Expand the sequence of Processes, so that there is one per output tuple, e.g. (123, (p1, p2)) -> (123, p1), (123, p2). - f 't, p: (p.pid, int(t), p.commandline)': Take the timestamp and Process as input, and generate (pid, timestamp as int, command line) as output. - sql "insert into process values(%s, %s, %s)": Take the triples from the previous command and dump them into a table in a database.