I'm trying to concatenate python variables into os.system, the command seems to execute but it doesn't take properly the value allocated.
I've tried using both os.system and subprocess, but none of them work. Here is some of my attempts.
interface = os.popen("netstat -i | awk '$1 ~ /^w/ {print $1}'")
os.system("iw dev %s station dump" % (interface))
.
interface = os.popen("netstat -i | awk '$1 ~ /^w/ {print $1}'")
os.system("iw dev" +interface+ "station dump")
.
p1 = subprocess.Popen(["netstat", "-i"], stdout=subprocess.PIPE)
p2 = subprocess.Popen(["awk", '$1 ~ /^w/ {print $1}'], stdin=p1.stdout,
stdout=subprocess.PIPE)
displayInterface = p2.communicate()[0].decode('ascii')
retrieveMac = subprocess.Popen(["iw", "dev", displayInterface, "station", "dump"])