Skip to content

Instantly share code, notes, and snippets.

@meelih
Created April 30, 2017 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meelih/a23d3a65e21745d8f4a9f7449accc3aa to your computer and use it in GitHub Desktop.
Save meelih/a23d3a65e21745d8f4a9f7449accc3aa to your computer and use it in GitHub Desktop.
import subprocess
import shlex
p1 = subprocess.Popen(shlex.split("ifconfig wlan0"),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
p2 = subprocess.Popen(shlex.split("awk '/inet addr:/ {print substr($2,6)}'"),stdin=p1.stdout,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out, err = p2.communicate()
print "out:", out[:-1]
print repr(out[:-1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment