title: What's the best way to nmap thousands of subnets in parallel from a script?
body: <p>To inventory a port in part of a Class-A network, I scan that as a few thousand Class-C networks using nmap.  I use parallel to run 32 subnet scan jobs at once.</p>
  <p>A minimized version of the script:</p>
  <pre class="lang-sh prettyprint-override"><code>while read subnet; do
      echo nmap -Pn -p&quot;$tcpport&quot; &quot;$subnet&quot; &gt;&gt; /tmp/nmap_parallel.list;
  done &lt; $subnets
  parallel -j32 &lt; /tmp/nmap_parallel.list
  wait
  echo &quot;Subnet scan for port $tcpport complete.&quot;
  </code></pre>
  <p>Problem with this approach is the script stops at parallel.</p>
  <p>Is there a better way to use parallel from a script?</p>