Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Having an issue writing a python script with vim

Hi hope someone on here can help me, I’m trying to write a python script using vim as the IDE then after saving changes and exiting running the code in the terminal:

#!/usr/bin/python
import sys
# then we import scapy:
from scapy.all import *
def PacketHandler(pkt):
print pkt.summary()
return
sniff(iface=sys.argv[1],count= int(sys.argv[2], prn= PacketHandler)

But, I’m getting a syntax error:

File "./packethandler.py", line 10
sniff=(iface =sys.argv[0], count =int(sys.argv[1]), prn =PacketHandler)
SyntaxError: invalid syntax

I can’t see anything wrong with the code, Does anyone maybe see something I’m missing ?

Thanks the Duke
[Image: Web-Logo-copy.gif]
Remove the first line and run it normally i.e. 'python yourprogram.py', see if your issue persists.
Electrical / Hardware Engineer. Need something made? Have an idea? I'm your guy.
(Jan 2, 2021 06:43 PM)SawCyanic Wrote:  Remove the first line and run it normally i.e. 'python yourprogram.py', see if your issue persists.

Are you referring to the #!/usr/bin/python Line at the top of the page ?
[Image: Web-Logo-copy.gif]
(Jan 3, 2021 12:33 AM)ThinWhiteDuke Wrote:  Are you referring to the  #!/usr/bin/python Line at the top of the page ?

Yes, the issue either lies in python not being in your $PATH or you not importing scapy correctly.
Electrical / Hardware Engineer. Need something made? Have an idea? I'm your guy.
(Jan 3, 2021 06:34 AM)SawCyanic Wrote:  Yes, the issue either lies in python not being in your $PATH or you not importing scapy correctly.
[url=https://stackoverflow.com/questions/13610064/scapy-all-import-does-not-work[/url]

Looks like someone on Stack Overflow has had the same issue
[Image: Web-Logo-copy.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by SigmaMay 2, 2021 02:13 PM 2 140 May 2, 2021 02:13 PM
Last Post: Ap3xDC
[Shell] by 0u1lawJul 18, 2020 11:18 AM 1 204 Jul 18, 2020 11:18 AM
Last Post: Pernat1y