ping

subprocess之check_out用法

大城市里の小女人 提交于 2019-12-12 20:07:35
在python3中使用subprocess的check_out方法时,因为该输出为byte类型,所以如果要查看具体的内容时需要进行转码,如果转码不对话,会影响内容输出的可读性,如下: #1,输出解码不带参数 1 # -*- coding:utf-8 -*- 2 3 import subprocess 4 cmd = r"ping www.baidu.com" 5 result = subprocess.check_output(cmd) 6 print(result.decode()) # decode中不带参数,默认是以utf-8解码 7 8 9 输出报错: 10 Traceback (most recent call last): 11 File "E:/debug.py", line 12, in <module> 12 print(result.decode()) # decode中不带参数 13 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 2: invalid continuation byte 14 15 Process finished with exit code 1 #2,输出解码带上 unicode_escape 参数,会显示乱码 1 # -*- coding:utf

Docker container connected by OVS+DPDK, `Ping` work but `iperf` NOT

末鹿安然 提交于 2019-12-12 18:41:20
问题 I am trying to build a platform using Docker , OVS+DPDK . 1. Set up DPDK + OVS I set up DPDK+OVS using dpdk-2.2.0 with openvswitch-2.5.1 . First, I compile the code of DPDK , set up hugepages. I do NOT bind NIC, because I don't get traffic from outside. Then, I compile the code of openvswitch , set with-dpdk . Start up OVS with the following script: #!/bin/sh sudo rm /var/log/openvswitch/my-ovs-vswitchd.log* export PATH=$PATH:/usr/local/share/openvswitch/scripts export DB_SOCK=/usr/local/var

如何通过 subprocess 持续获取输出内容

北城余情 提交于 2019-12-12 17:00:40
在实际应用中会用到subprocess的Popen方法执行一些命令,而我们需要通过执行这个命令的来获取输出进行一些信息记录或者分析使用,如果是很快就可以执行完的那还好,有时需要持续跟踪内容的输出,比如大型服务器的内存、CPU、进程监控等,这是一个持续的过程,那么就需要想方设法将输出的内容实时的记录到控制台或者文件中,下面是举例一个ping指令,后面带上 -t 参数获取实时的ping情况,代码如下: 1 # -*- coding:utf-8 -*- 2 3 import subprocess 4 cmd = r"ping www.baidu.com -t" 5 result = subprocess.Popen(cmd, stdout=subprocess.PIPE) # 将输出内容存至缓存中 6 while True: # 将内容持续输出 7 with open("ping.txt", "a", encoding="utf-8") as f: 8 f.write(result.stdout.readline().decode("gbk").strip() + "\n") # 先去除每一行末尾的制表符和换行符,然后再加上换行符,使写入文件中的内容不会有空行 然后在该代码路径下找到ping.txt文件并打开显示如下,挺整齐的: 如果不在代码中第8行增加去除末尾的制表符和换行符的话

excel vba ping list of computers

不问归期 提交于 2019-12-12 14:12:52
问题 I am working on a project. My goal is, to ping all of the computers from an excel list, but can't figure out why it isn't working. I am quite new at this programming language, and I am sure that I miss out something, because I get the error message: Object required so here is my code the main: Sub pingall_Click() Dim c As Range c = Target.Name For Each c In Range("A1:N50") If (Left(c, 1) = "C" Or Left(c, 1) = "T") And IsNumeric(Right(c, 6)) And Len(c) = 7 Then c = sPing(c) If c = "timeout"

Make PHP socket_connect timeout

有些话、适合烂在心里 提交于 2019-12-12 07:06:51
问题 I have a small application I created to analyze the network connection. It runs from a browser and connects to a local PHP/Apache server. It then asks PHP to send a ping packet through a raw socket. THe problem is that if the host I am trying to ping isn't alive or won't answer to pings, we never get an answer from the server. I beleave the socket request lives until apache is restarted. I have been getting mixed results from my application lately and I am blaming apache using too many

Android - Large amount of tie taken to check Internet connectivity using ping

可紊 提交于 2019-12-12 05:49:33
问题 I have written some code to ping Google to check Internet connectivity. The app works except that it takes a lot of time to send back the response (up-to 1 min). This happens especially when Mobile Network is turned ON but there is no Internet connectivity I would appreciate it if you would help me find a solution The layout consists of just a Button. Following is my Java code: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout

How to ping multiple ip address

依然范特西╮ 提交于 2019-12-12 04:38:13
问题 I want to ping 500 times three different ip address SIMULTANEOUSLY. If these pings are not the same time that will be an easy question. Somebody may say about open three cmd and start to ping your ip in each one.... ummm thats work But I'am finding to smarter way? I searched and I found one way in Linux, I'm working on Win7. 回答1: If you want to compare delays afterwards you could so something like this: @echo off setlocal start "" "%COMSPEC%" /c ping -n 500 192.168.1.23 ^>log1.txt start "" "

How to catch ping error with Python?

南楼画角 提交于 2019-12-12 04:34:34
问题 Here is my simple example: import subprocess cmd = 'ping something.local -c 1' tail = 'tail -n 3' ping = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE) tail = subprocess.Popen(tail.split(' '), stdin=ping.stdout, stdout=subprocess.PIPE) ping.stdout.close() out, err = tail.communicate() print 'Print values:' print out print err And here is the output example of script: [~/python]$ python ping_stats.py ping: cannot resolve tpeo.local: Unknown host Print values: None So, my variables

Locating computer on subnet/network

淺唱寂寞╮ 提交于 2019-12-12 01:34:49
问题 Here is situation: I have special device that I can communicate via ethernet. It's connected to my computer via ethernet cable and the problem is that these devices are changed from time to time and they have different IP addresses. They always start 192.168. and the rest might be different. Device answers to IMCP (ping). Right now we have a list of IPs and we ping them to find device. We always know that there is only two devices on this network (this special device and laptop). So I am

ansible的基础概念

丶灬走出姿态 提交于 2019-12-11 23:07:57
一、ansible 基础概念: 1. 什么是ansible 他是一个“配置管理工具”,他是一个“自动化运维工具” 2.ansible能做什么? 正如其他的配置管理工具一样,ansible可以帮助我们完成一些批量任务,或者完成一些需要经常重复的工作。 比如:同时在100台服务器上安装Nginx服务,并在安装后启动他们: 比如:姜末个文件一次性拷贝到100台服务器上。 等等。。。。 这些场景中我们都可以使用到ansible。 3.为什么使用 也许有些人看到这里,你可能说我写一些脚本,也能满足上面的工作场景,为什么还要使用ansible?没错,使用脚本可以完成以上的工作,但是还是ansible更好。因为ansible支持一些优秀的特性,比如“幂等性”。 “幂等性”是什么意思?就是把一个文件拷贝到目标主机上,但是你不知道之前是否有这么操作过,那么用了ansible就会自动判断。ansible是以结果为导向的,我们指定一个 目标状态 ,ansible会自动判断,当前状态,和目标状态是否一致。如果一致,则不进行任何操作,如果不一致,那么就会将 当前状态替换成目标状态。这就是‘ 幂等值 ’。 幂等性,可以保证我们重复的执行同一项操作时,得到的结果是一样的,这种特性在很多场景中相对于脚本来说都有一定的优势,丹丹这样说,可能不好理解,当你在后面真正使用时,自然会自己理解的体会的。 4.