473,218 Members | 1,696 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,218 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 1323
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.