[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: Re: get same info as ipconfig?
From: djberg96 () hotmail ! com (Daniel Berger)
Date: 2004-06-30 3:52:53
Message-ID: 6e613a32.0406291948.53e6d981 () posting ! google ! com
[Download RAW message or body]
piir@earthlink.net (Todd Gardner) wrote in message \
news:<9b849915.0406291338.7e1fc6e3@posting.google.com>...
> djberg96@hotmail.com (Daniel Berger) wrote in message \
> news:<6e613a32.0406281247.52deb55e@posting.google.com>...
> > piir@earthlink.net (Todd Gardner) wrote in message \
> > news:<9b849915.0406280231.d91f103@posting.google.com>...
> > > Hello Everyone,
> > >
> > > Is there a cross platform command to get the same info that ipconfig
> > > [w2k] or ifconfig[POSIX] returns directly in Ruby?
> > >
> > > Thanks,
> > >
> > > Todd
> >
> > I see Sam mentioned sys-host (one of my packages), but it's not very
> > useful at the moment. However, I plan to rewrite the Windows portion
> > to use OLE + WMI. You can get the info you need on Windows like this:
> >
> > require "win32ole"
> >
> > ole = WIN32OLE.connect("winmgmts://")
> >
> > # Avoid non-working adapters by setting 'IPEnabled' to true
> > query = "select * from Win32_NetworkAdapterConfiguration where
> > IPEnabled = True"
> >
> > ole.ExecQuery(query).each{ |nic|
> > p nic.IpAddress
> > p nic.IpSubnet
> > p nic.DefaultIPGateway
> > }
> >
> > Regards,
> >
> > Dan
>
> Hell Dan,
>
> When I run the above code on w2k I get this.
>
> =============================
> ["192.168.1.115"]
> ["255.255.255.0"]
> ["192.168.1.1"]
>
> And then a modal dialog pops up and takes focus.
>
> [dialog]
> Run time error!
> Program: C:\ruby\bin\\rubyw.exe
> This application requested the run time to terminate in an unusual
> way. Please contact the application support team for more
> information."
> ============================
Hi Todd,
Hm...I suspect you need to update your version of win32ole. The
version that comes with 1.8.1 is 0.5.4, but the latest is 0.5.5 (and
will be part of 1.8.2).
> Might you have any idea how I can determine what my WAN IP address is?
> It is not in ipconfig. My Linksys router does show it to me at...
Take a look at the attributes available for the
Win32_NetworkAdapterConfiguration class at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_networkadapterconfiguration.asp
If none of those fields fit your needs, you'll have to dig around and
see what you can find. Off the top of my head I'm not sure.
BTW, I should have a new release of sys-host out this week.
Regards,
Dan
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic