Hack Forums
[Python] Having an issue writing a python script with vim - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] Having an issue writing a python script with vim (/showthread.php?tid=6130964)



Having an issue writing a python script with vim - ThinWhiteDuke - Jan 2, 2021

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


RE: Having an issue writing a python script with vim - SawCyanic - Jan 2, 2021

Remove the first line and run it normally i.e. 'python yourprogram.py', see if your issue persists.


RE: Having an issue writing a python script with vim - ThinWhiteDuke - Jan 3, 2021

(Jan 2, 2021 06:43 PM)Enginerd 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 ?


RE: Having an issue writing a python script with vim - SawCyanic - Jan 3, 2021

(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.


RE: Having an issue writing a python script with vim - ThinWhiteDuke - Jan 3, 2021

(Jan 3, 2021 06:34 AM)Enginerd 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