Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So I revisited this question, and found two solutions (I switched to Python 2.7 sometime ago, so I'm not sure about Python 2.6, but it should be the same.):</p> <ol> <li><p>Replace <strong>find</strong> with <strong>findstr</strong>, and remove doublequotes</p> <pre><code>output = subprocess.Popen(['netstat','-ano','|','findstr',':80'], stdout=subprocess.PIPE, shell=True) .communicate() </code></pre> <p><strong>But this doesn't explain why "find" cannot be used, so:</strong></p></li> <li><p>Use string parameter instead of list</p> <pre><code>output = subprocess.Popen('netstat -ano | find ":80"', stdout=subprocess.PIPE, shell=True) .communicate() </code></pre> <p>or</p> <pre><code>pipeout = subprocess.Popen(['netstat', '-ano'], stdout = subprocess.PIPE) output = subprocess.Popen('find ":80"', stdin = pipeout.stdout, stdout = subprocess.PIPE) .communicate() </code></pre></li> </ol> <p>The problem arise from the fact that: ['find','":80"'] is actually translated into ['find,'\":80\"']. Thus the following command is executed in Windows command shell:</p> <pre><code>&gt;find \":80\" Access denied - \ </code></pre> <p>Proof:</p> <ul> <li><p>Running:</p> <pre><code>output = subprocess.Popen(['echo','find','":80"'], stdout=subprocess.PIPE, shell=True) .communicate() print output[0] </code></pre> <p>returns:</p> <pre><code>find \":80\" </code></pre></li> <li><p>Running:</p> <pre><code>output = subprocess.Popen('echo find ":80"', stdout=subprocess.PIPE, shell=True) .communicate() print output[0] </code></pre> <p>returns:</p> <pre><code>find ":80" </code></pre></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload