Ohood
Posts: 7
Joined: Sat Mar 10, 2018 12:44 pm

arp-scan -l in python

Wed Apr 01, 2020 1:10 pm

Hi All ,

I want to run an arp-scan from python script not from cmd line, therefore, I have write the code below but it does not show anything. Can you help please ?



import socket
from subprocess import call
call(["arp-scan -l"])

-------------------------------------------------------------
also, I change the call to be : (["arp","-scan", "-l"]) but still show nothing but when writing it in the cmd line it's run the scan

pcmanbob
Posts: 9465
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: arp-scan -l in python

Wed Apr 01, 2020 2:16 pm

If you want to use subprocess to run the arp scan then you need to do it like this

Code: Select all

import subprocess

p = subprocess.Popen(" sudo arp-scan -l", stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
status = p.wait()

print(output)
print(err)
were output contains the results of the scan and err contains any error messages
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Python”