From 47fffa42392f40266c80819cfb8820a6695b1d0d Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Thu, 10 Oct 2013 11:04:36 +0200 Subject: [PATCH] transpose-simple: simple transpose with paste --- Makefile | 2 +- transpose/transpose-simple | 3 +++ w4it-for-port-open/w4it-for-port-open | 14 ++++---------- 3 files changed, 8 insertions(+), 11 deletions(-) create mode 100644 transpose/transpose-simple diff --git a/Makefile b/Makefile index 0d4fb37..49da07e 100644 --- a/Makefile +++ b/Makefile @@ -16,5 +16,5 @@ timestamp/timestamp.1: timestamp/timestamp pod2man timestamp/timestamp > timestamp/timestamp.1 install: - parallel ln -sf `pwd`/{}/{} /usr/local/bin/{} ::: blink reniced em field forever neno rn stdout tracefile w4it-for-port-open upsidedown histogram goodpasswd mtrr not summer timestamp + parallel ln -sf `pwd`/{}/{} /usr/local/bin/{} ::: blink reniced em field forever neno rn stdout tracefile w4it-for-port-open upsidedown histogram goodpasswd mtrr not summer timestamp transpose parallel ln -sf `pwd`/{} /usr/local/share/man/man1/{/} ::: */*.1 diff --git a/transpose/transpose-simple b/transpose/transpose-simple new file mode 100644 index 0000000..12c639c --- /dev/null +++ b/transpose/transpose-simple @@ -0,0 +1,3 @@ +Can it be done more simple? + +zcat D.gz | perl -ne 's/\s+/\n/g; open(OUT,">","out".(++$out)); print OUT' ; paste out* | pigz >Dt.gz diff --git a/w4it-for-port-open/w4it-for-port-open b/w4it-for-port-open/w4it-for-port-open index cc21210..92df5ec 100755 --- a/w4it-for-port-open/w4it-for-port-open +++ b/w4it-for-port-open/w4it-for-port-open @@ -3,7 +3,7 @@ HOST=$1 PORT=$2 -TCPTRACEROUTE=$( which tcptraceroute ) +NC=$( which nc ) usage () { echo "Usage:" @@ -33,13 +33,7 @@ print_up_but_port_closed () { port_is_open () { # If tcptraceroute stops working use: # echo | nc -w 2 $HOST $PORT || failed - OUT=$(tcptraceroute -f 255 -m 255 -q 1 -w 1 $HOST $PORT 2>&1) - if echo "$OUT" | grep 'Destination not reached' >/dev/null ; then - print_not_reachable - OPEN=no - elif echo "$OUT" | grep '\[closed\]' >/dev/null ; then - print_up_but_port_closed - sleep 1 + if $NC -z -w 2 $HOST $PORT 2>&1 ; then OPEN=no else OPEN=yes @@ -52,8 +46,8 @@ fi if [ -z "$PORT" ] ; then PORT=22 fi -if [ -z "$TCPTRACEROUTE" ] ; then - echo "Error, 'tcptraceroute' not installed." +if [ -z "$NC" ] ; then + echo "Error, 'nc' not installed." exit 2 fi