"Kingsley Hendrickse" <KHendric / thoughtworks.com> wrote:

> ________________
> class Test
>         def ipfind
>         a = `ipconfig`
>         a =~ /\d\d\d\.\d\d\.\d\d\d\.\d\d/
>         ip = $~
>         return ip
>         end
> end
> i = Test.new.ipfind
> puts i
> _______________
>

Not directly related, but you can find your IP address with ...


require 'socket'
i = IPSocket.getaddress(Socket.gethostname)
puts i



... although I just tried that in a win98 DOS box as

ruby -rsocket -e'puts IPSocket.getaddress(Socket.gethostname)'

and got no reply (& no error).

Should work ?  (Probably my set-up; never use cmd line.)


daz