--
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
hmm since u asking this, anyone here played with snmpd before?
what is the easiest snmpd.conf file that allows public query on CPU and harddisk usage.....
Umarzuki Mochlis wrote:Hi all,
I wonder how I can output network interfaces with python the same way I can with these commands on linux
--sudo ifconfig | cut -d " " -f 1 > ifconfig.txtsed '/ *#/d; /^ *$/d' < ifconfig.txt
--
Regards,
Umarzuki Mochlis
http://debmal.my
hmm since u asking this, anyone here played with snmpd before?
what is the easiest snmpd.conf file that allows public query on CPU and harddisk usage.....
--
Umarzuki Mochlis wrote:--Hi all,
I wonder how I can output network interfaces with python the same way I can with these commands on linux
sudo ifconfig | cut -d " " -f 1 > ifconfig.txtsed '/ *#/d; /^ *$/d' < ifconfig.txt
--
Regards,
Umarzuki Mochlis
http://debmal.my
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
popen _is_ in the subprocess library (or do u mean os.popen or
popen2?) , and subprocess been around for ages, since 2.4
http://docs.python.org/dev/library/subprocess
no guarantee to work on all os, as not all os have the same command tools ..
-- 
Mohd Izhar Firdaus Bin Ismail
Amano Hikaru  天野晃 「あまの ひかる」
Fedora Malaysia Contributor & Ambassador
http://fedoraproject.org/wiki/MohdIzharFirdaus
http://blog.kagesenshi.org
92C2 B295 B40B B3DC 6866  5011 5BD2 584A 8A5D 7331
and different OS might have different output format of a same tool ..
--
You received this message because you are subscribed to the Google Groups "python.my" group.
To post to this group, send email to pyth...@googlegroups.com.
To unsubscribe from this group, send email to pythonmy+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythonmy?hl=en.
Since the question is Linux specific, wouldn't it be easier to just parse /proc/net/dev ?
for l in open('/proc/net/dev'):
    if ':' in l:
       print l.split(':')[0].strip()
> --
> You received this message because you are subscribed to the Google Groups
> "python.my" group.
> To post to this group, send email to pyth...@googlegroups.com.
> To unsubscribe from this group, send email to
> pythonmy+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pythonmy?hl=en.
>
-- 
On Thu, Feb 4, 2010 at 2:10 PM, ApOgEE <jeru...@gmail.com> wrote:erm ......
> On Thu, Feb 4, 2010 at 11:42 AM, E A Faisal <eafa...@gmail.com> wrote:
>>
>> Since the question is Linux specific, wouldn't it be easier to just parse
>> /proc/net/dev ?
>
>
> E A Faisal, yes it is... I'm just having fun coding. So, I tried your
> suggestion and here is the second version of the morning code:
for l in open('/proc/net/dev'):
if ':' in l:
print l.split(':')[0].strip()
at least its not like perl .. :P
>
> for l in open('/proc/net/dev'):
>    if ':' in l:
>          if int(l.split(':')[1].replace(' ','')) > 0:
>                print l.split(':')[0].strip()
use strip() is better than replace(' ','') ..
and btw .. having data transfered by the interface doesnt necessarily
means the interface is up ..
compare the outputs ..
from subprocess import Popen,PIPE
p = Popen('ifconfig',stdout=PIPE)
p.wait()
for l in p.stdout:
    ls = l.split(' ')
    if ls[0].strip():
       print ls[0].strip()
print '----'
for l in open('/proc/net/dev'):
    if ':' in l:
       print l.split(':')[0].strip()
print '----'
for l in open('/proc/net/dev'):
    if ':' in l:
       if int(l.split(':')[1].replace(' ','')) > 0:
          print l.split(':')[0].strip()
my output:
eth2
lo
tun0
virbr0
wlan1
wmaster0
----
lo
eth2
wmaster0
wlan1
vboxnet0
pan0
virbr0
tun0
----
lo
wlan1
virbr0
tun0
>
>
> --
> Best Wishes,
>
> M. Fauzilkamil Zainuddin
> Software Engineer
> Persiasys Sdn. Bhd.
> ----------------------------------------------------
> ApOgEE a.k.a JeRuNgKuN
> ----------------------------------------------------
> https://edge.launchpad.net/~apogee - ApOgEE on LaunchPad
> http://artofapogee.blogspot.com - Art Of ApOgEE
> http://coderstalk.blogspot.com - Coder's Talk
> ----------------------------------------------------
>
ignore this
> use strip() is better than replace(' ','') ..
hehe :P .. different usecase ..