Skip to content

Instantly share code, notes, and snippets.

@ttreitlinger
Created May 17, 2011 15:31
Show Gist options
  • Save ttreitlinger/976700 to your computer and use it in GitHub Desktop.
Save ttreitlinger/976700 to your computer and use it in GitHub Desktop.
executing netcat from a python script
import os
import subprocess
test_cmd = 'netcat -vz 193.1.172.59 75-85'
expected = 'vega.ucd.ie [193.1.172.59] 80 (http) open'
process = subprocess.Popen(test_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
err = process.stderr.read()
print str(err)
@inversepolymath
Copy link

I was having an issue with netcat and subprocess. This helped me tremendously!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment