pentester
2012-09-23 13:22:49 UTC
If I launch a python script from the command line, there is an error message.
But launching python from the command line and add the script as an argument, works fine.
I have included a simple example as proof of concept. It just prints de __doc__ of scapy's sr function.
This is the script:
$ cat tmp.py
#! /usr/bin/python
from scapy.all import *
print ("This is sr.__doc__\n%s") % (sr.__doc__)
This is the output:
$ python tmp.py
This is sr.__doc__
Send and receive packets at layer 3
nofilter: put 1 to avoid use of bpf filters
retry: if positive, how many times to resend unanswered packets
if negative, how many times to retry when no more packets are answered
timeout: how much time to wait after the last packet has been sent
verbose: set verbosity level
multi: whether to accept multiple answers for the same stimulus
filter: provide a BPF filter
iface: listen answers only on the given interface
Everything works as expected. It is clear the scapy.all module can be found.
But when I launch the script without invoking python first, it fails:
$ ./tmp.py
Traceback (most recent call last):
File "./tmp.py", line 2, in <module>
from scapy.all import *
ImportError: No module named scapy.all
I googled but answers to similar questions didn't solve the issue so far. Does anyone has a clue what is happening here?
For what it's worth:
- It fails on Mac (Darwin Kernel Version 10.8.0), but works on linux (Backtrack distro)
- scapy is installed using macport
$ port installed | grep -i scapy
py26-scapy @2.1.0_0 (active)
cr
But launching python from the command line and add the script as an argument, works fine.
I have included a simple example as proof of concept. It just prints de __doc__ of scapy's sr function.
This is the script:
$ cat tmp.py
#! /usr/bin/python
from scapy.all import *
print ("This is sr.__doc__\n%s") % (sr.__doc__)
This is the output:
$ python tmp.py
This is sr.__doc__
Send and receive packets at layer 3
nofilter: put 1 to avoid use of bpf filters
retry: if positive, how many times to resend unanswered packets
if negative, how many times to retry when no more packets are answered
timeout: how much time to wait after the last packet has been sent
verbose: set verbosity level
multi: whether to accept multiple answers for the same stimulus
filter: provide a BPF filter
iface: listen answers only on the given interface
Everything works as expected. It is clear the scapy.all module can be found.
But when I launch the script without invoking python first, it fails:
$ ./tmp.py
Traceback (most recent call last):
File "./tmp.py", line 2, in <module>
from scapy.all import *
ImportError: No module named scapy.all
I googled but answers to similar questions didn't solve the issue so far. Does anyone has a clue what is happening here?
For what it's worth:
- It fails on Mac (Darwin Kernel Version 10.8.0), but works on linux (Backtrack distro)
- scapy is installed using macport
$ port installed | grep -i scapy
py26-scapy @2.1.0_0 (active)
cr