Skip to content

Instantly share code, notes, and snippets.

@tdrjnr
Forked from ttreitlinger/test_netcat.py
Created February 14, 2019 19:20
Show Gist options
  • Select an option

  • Save tdrjnr/fc8f3db211501fa7d3d87c7906ab51f8 to your computer and use it in GitHub Desktop.

Select an option

Save tdrjnr/fc8f3db211501fa7d3d87c7906ab51f8 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment