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
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
piir@earthlink.net (Todd Gardner) writes:
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
Nope, not really, I don't think. If you want to figure out the address
of the interface closest to the Internet, as far as I know the most
portable way is to open a socket to a machine elsewhere on the Internet
and look at which source address the operating system chose.
mikael
You might have luck with `sys-host':
http://ruby-sysutils.sourceforge.net/host.html
On Mon, 28 Jun 2004 19:32:57 +0900, Todd Gardner <piir@earthlink.net> wrote:
Is there a cross platform command to get the same info that ipconfig
[w2k] or ifconfig[POSIX] returns directly in Ruby?
--
Sam
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
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,
>
> ToddI 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.
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...
http://192.168.1.1/Status.htm
LAN:
(MAC Address: 00-04-5A-EF-5C-9F)
IP Address: 192.168.1.1
Subnet Mask: 255.255.255.0
DHCP server: Enabled
WAN:
(MAC Address: 00-04-5A-EF-5C-A0)
IP Address: 68.164.157.203
DNS: 207.69.188.186
207.69.188.185
0.0.0.
I have DSl and the IP address earthlink DSL gives me changes quite
frequently. Every few days.
Thanks,
Todd
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,
>
> DanHell 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
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