NEWBIE: Tokenize command output

Lorenzo Thurman lorenzo at nospamthethurmans.com
Thu May 11 17:28:25 CEST 2006


This is what I have so far:

//
#!/usr/bin/python

import os

cmd = 'ntpq -p'

output = os.popen(cmd).read()
//

The output is saved in the variable 'output'. What I need to do next is 
select the line from that output that starts with the '*'

     remote           refid      st t when poll reach   delay   offset  
jitter
=========================================================================
=====
+ntp-1.gw.uiuc.e 128.174.38.133   2 u  479 1024  377   33.835   -0.478   
3.654
+milo.mcs.anl.go 130.126.24.44    3 u  676 1024  377   70.143    1.893   
1.296
*caesar.cs.wisc. 128.105.201.11   2 u  635 1024  377   29.514   -0.231   
0.077


>From there, I need to tokenize the line using the spaces as delimiters. 
Can someone give me some pointers?
Thanks



More information about the Python-list mailing list