title: Run the output from Masscan in a variable using sh script
body: <p>I am trying to capture the output from masscan in a loop variable.
  The intention is to process the data during a live scan
  Something like</p>
  <pre class="lang-sh prettyprint-override"><code>while IPST=&quot;$(masscan -iL list.txt -p80 )&quot;   #scan masscan output in var IPS  
    do 
        # remove &quot;Discovered open port 80/tcp on&quot; from var $IPST and put the clean ip in var $IP 
        IP=&quot;$(IPST=&quot;$(sed s'/\[//' | sed -r 's/Discovered open port 80tcp on//') # not tested yet
        echo $IP
        ...   
  </code></pre>
  <p>but i have no idea how to do this.
  does anyone know how to do it</p>
  <p>EDIT:  (i started trying for loops)<br />
  just realized in the shell &quot;masscan &gt;&gt; filename.TXT&quot; give the best results for me. so in a loop it would be something like.</p>
  <pre class="lang-sh prettyprint-override"><code> for I in $( masscan -iL italy.txt -p80 &gt;&gt; ThisIneedInAvariable.txt );  
   do 
  </code></pre>
  <p>but i need ThisIneedInAvariable.txt you guessed it, in a variable</p>
  <p>unfortunately this don't works</p>
  <pre class="lang-sh prettyprint-override"><code> for I in $( masscan -iL italy.txt -p80 &gt;&gt; $variable );  
   do 
  </code></pre>
  <p>this gives &quot;masscan: No such file or directory&quot;</p>
  <pre class="lang-sh prettyprint-override"><code> for VARIABLE in $(&lt; masscan -iL italy.txt -p80) ;  
   do 
  </code></pre>
  <p>I need it in a loop, the complete script is based on the output from masscan and should end when masscan is done, in fact i am trying creating a stream.</p>