[RndTbl] interesting unix pipe problem (stop whole pipe chain on first match)

Trevor Cordes trevor at tecnopolis.ca
Sun May 31 01:35:15 CDT 2020


Argh, sorry... for testing I was using a slightly bogus ip range...
please change the 254-254 to 100-254.  The corrected command line is
below:

echo 192.168.101 | \
timeout 30 bash -c \
 " \
  sint=\$(cat); \
  (nmap -ddd -vvv --send-ip \
  --host-timeout 5s --max-rtt-timeout 1s --initial-rtt-timeout 500ms \
  --max-retries 1 -S \$sint.1 -sn -PE \$sint.2 \$sint.100-254 2>&1 & \
  echo \$! >&3) \
  3>pidnmap \
  | grep --line-buffered -P 'RCVD.{0,30}?ICMP.{0,60}?Echo reply' \
  | (head -1 && kill \$(<pidnmap) 2>&1) \
" \
|grep RCVD || echo "no hosts found"


And for some reason when I paste this from a my gui mail client it has
syntax errors, but when I paste it from a tui mail client it works
fine... YMMV.  I guess I could post the one-line version:

echo 192.168.101 | timeout 30 bash -c "sint=\$(cat); (nmap -ddd -vvv --send-ip --host-timeout 5s --max-rtt-timeout 1s --initial-rtt-timeout 500ms --max-retries 1 -S \$sint.1 -sn -PE \$sint.2 \$sint.100-254 2>&1 & echo \$! >&3) 3>pidnmap | grep --line-buffered -P 'RCVD.{0,30}?ICMP.{0,60}?Echo reply' | (head -1 && kill \$(<pidnmap) 2>&1)" |grep RCVD || echo "no hosts found"


More information about the Roundtable mailing list