delay = receive_one_ping(my_socket, my_ID, timeout) my_socket.close()exceptsocket.error, (errno, msg):iferrno ==1:# Operation not permittedmsg = msg + (" - not root.")raisesocket.error(msg)#raise # raise the original errorreturndelaydefverbose_ping(dest_addr, timeout =2, count ...
def checksum(source_string):"""I'm not too confident that this is right but testing seemsto suggest that it gives the same answersasin_cksuminping.c"""sum =0count_to= (len(source_string) /2) *2forcountinxrange(0, count_to,2):this= ord(source_string[count +1]) *256+ord(source...
def ping_once(self): “”“ Returns the delay (in seconds) or none on timeout. ”“” icmp = socket.getprotobyname(“icmp”) try: sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp) except socket.error as e: if e.errno == 1: # Not superuser, so operation not permitted...
my_socket=socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)exceptsocket.error as e:ife.errno == 1:#Operation not permittedmsg =("- Note that ICMP messages can only be sent from processes""running as root.")raisesocket.error(msg)raise#raise the original errormy_id= os.getpid() & ...
Hello Alessandro, I get "PermissionError: [Errno 1] Operation not permitted" during call of ping(). I run it as normal user and OS side ping works well. $ cat /etc/SuSE-release SUSE Linux Enterprise Server 12 (x86_64) VERSION = 12 PATCHL...
defping_once(self):""" Returns thedelay(inseconds)or none on timeout.""" icmp=socket.getprotobyname("icmp")try:sock=socket.socket(socket.AF_INET,socket.SOCK_RAW,icmp)except socket.error,(errno,msg):iferrno==1:# Not superuser,so operation not permitted msg+="ICMP messages can only be...
errno == 1: # Not superuser, so operation not permitted e.msg += "ICMP messages can only be sent from root user processes" raise socket.error(e.msg) except Exception as e: print("Exception: %s" %(e)) my_ID = os.getpid() & 0xFFFF self.send_ping(sock, my_ID) delay = self....
Python ping 模块 print socket.gethostbyname('www.baidu.com') 1. fping功能 https://www.cnblogs.com/zhoujie/p/python17.html 适合服务器数量较大时使用,fping命令,它是对一个文件的批量ping,瞬间完成的,如果ping不通,那就较慢,日常ping不通的毕竟是少数,所以这个非常适用。来感受一下,它ping的结果,...
# Operation not permitted msg=msg+( " - Note that ICMP messages can only be sent from processes" " running as root." ) raisesocket.error(msg) raise# raise the original error my_ID=os.getpid() &0xFFFF send_one_ping(my_socket, dest_addr, my_ID) ...
so operation not permitted msg += "ICMP messages can only be sent from root user processes" raise socket.error(msg) except Exception, e: print "Exception: %s" %(e) my_ID = os.getpid() & 0xFFFF self.send_ping(sock, my_ID) delay = self.receive_ping(sock, my_ID, self.timeout) ...