471,354 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 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 1250
ghostdog74
511 Expert 256MB
pls see my reply from the other forum you posted to
Sep 26 '07 #2

Post your reply

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

Similar topics

5 posts views Thread by hokieghal99 | last post: by
3 posts views Thread by Jason Rodman | last post: by
8 posts views Thread by KJ | last post: by
21 posts views Thread by Neel | last post: by
6 posts views Thread by Dave Marden | last post: by
1 post views Thread by DannyMc | last post: by

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.