473,398 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

string right value from ping

Hi,

Need help to filter the proper value from a string,
Here is a display from a ping command:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Pinging 10.2.3.6 with 32 bytes of data: 
  3. Request timed out. 
  4. Request timed out. 
  5. Request timed out. 
  6.  
  7. Ping statistics for 10.2.3.6: 
  8. Packets: Sent = 3, Received = 2, Lost = 1 (66% loss),
  9.  
  10.  
Here is the result of my script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. #IP no. 1: 10.2.3.6
  3. #IP no. 2: 0
  4. ['10.20.3.121']
  5. 66% 
  6.  
  7.  
I'm wondering how can I filter Ping statistics for 10.2.3.6 to be display beside 66% and send the result to a folder?


and here is part of my script:

Expand|Select|Wrap|Line Numbers
  1.  
  2. def print_results(): 
  3.     for result in results: 
  4.         for line in result: 
  5.             print line 
  6.  
  7. def analyse(): 
  8.     for result in results: 
  9.         for line in result: 
  10.             mo = re.search("loss" , line)
  11.             if(mo): 
  12.              startopenbracket = line.find("(") 
  13.              startloss = line.find("loss") 
  14.               print line [startopenbracket+1:startloss]
  15.  
  16.  
Sep 26 '07 #1
1 1329
ghostdog74
511 Expert 256MB
pls see my reply from the other forum you posted to
Sep 26 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: hokieghal99 | last post by:
How does one tell if a string contains a certain substring? For example: $a = popen("/bin/ping -c1 $rhost", "r"); $read = fread($a, 1024); pclose($a); if($read contains "1 received") {...
3
by: Jason Rodman | last post by:
I have downloaded every example on how to create a ping utility in .Net in both VB and C#, but have been disappointed with the results. I have YET to find an example that returns consistent results...
2
by: Eric Wenger | last post by:
I'm pretty new to C# and I'm trying to do what I believe should be a simple thing. I want to modify a program that is using the System.Net.NetworkInformation.Ping class to have some custom...
8
by: KJ | last post by:
This is kind of confusing. I'm trying to create a connection string to connect to a database on another server supposely in the network. Now if I set the Data Source = dbservername on my local...
21
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
5
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
1
by: DannyMc | last post by:
Hi, I am writing a PHP script to get a ping reply from my LAN PC. So, my idea is like this, when i mouseover/mouse click to the "hostname" display on the web. There will be a hint box appear and...
4
by: vishal1082 | last post by:
okay so i have this situation: i have to get round trip time (ping) from a IP, but if i do it in the UI thread it freezes if the ping is high, for example > 300, now to stop the UI to hang i made...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.