I have a SQLite3 table named DEVICES that has a list of ip addresses from my home network. I want to run an arp-scan against those ip addresses. Notice, this is the data in my DEVICES table exported to a csv file:
ipAddr,macAddr,Description,OS,Notes
192.168.0.1,,,,
192.168.0.134,,,,
Now when I run the following code I feel like the data I'm getting back from the SQLite3 is not correct. Notice the PRINT stmts:
cursorObj.execute("SELECT ipAddr FROM Devices")
rows = cursorObj.fetchall()
print("rows="+str(rows))
for ipAddr in rows:
print("working on ipAddr="+str(ipAddr))
macAddr = os.popen('sudo arp-scan '+str(ipAddr)+' | grep MAC: | cut -f 6- -d \' \' | cut -c1-17').read()
print("MAC: "+macAddr+" found for IP: "+str(ipAddr))
MY LOGS:
rows=[('192.168.0.1',), ('192.168.0.134',)]
working on ipAddr=**('**192.168.0.1**',)**
/bin/sh: 1: Syntax error: "(" unexpected
MAC: found for IP: **('192.168.0.1',)**
Why is my "ipAddr=('192.168.0.1',)" and not simply "ipAddr=192.168.0.1" just as it is in the DB?