diff options
author | David Timber <dxdt@dev.snart.me> | 2024-10-25 23:39:16 +0200 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2024-10-25 23:39:16 +0200 |
commit | 57d2e809972f25ccdd9f1afe6088199cbf975cb8 (patch) | |
tree | 58933f046b1e32de389b36c3920b20bdc3a34dbc /query-prefixes |
Initial commit
Diffstat (limited to 'query-prefixes')
-rwxr-xr-x | query-prefixes | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/query-prefixes b/query-prefixes new file mode 100755 index 0000000..dc1bff6 --- /dev/null +++ b/query-prefixes @@ -0,0 +1,42 @@ +#!/bin/bash +. common.sh + +PIPE_NAME="$$.fifo.tmp" + +if [ "$1" == "-6" ]; then + Q_PREFIX='!6' +else + Q_PREFIX='!g' +fi + +read_aslist () { + local asn + + while read asn + do + echo ${asn} >&3 + echo ${Q_PREFIX}${asn} + done +} + +output_filter () { + local a + local b + + while read -u 3 a && read -d '' b + do + printf '%-12s\t%s\n' "$a" "$b" + done +} + + +mkfifo "$PIPE_NAME" || exit 1 +grep -Eoi 'AS[0-9]+' | + read_aslist 3> "$PIPE_NAME" | + open_db | + extract_answer | + output_filter \ + 3< "$PIPE_NAME" & +rm "$PIPE_NAME" + +wait |