On Jul 3, 2007, at 1:08 PM, Jeff Barczewski wrote:

> On windows I get ifconfig not found exception
>
> testara.rb:9:in `popen': No such file or directory - ifconfig
> (Errno::ENOENT)
>    from testara.rb :9:in `mac_address'
>    from testara.rb:8:in `mac_address'
>    from testara.rb:23
>


argh.  cut and paste error - one more time....

     def mac_address
       return @mac_address if defined? @mac_address
       re = %r/[^:\-](?:[0-9A-Za-z][0-9A-Za-z][:\-]){5}[0-9A-Za-z] 
[0-9A-Za-z][^:\-]/o
       cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig',  
'ipconfig /all'

       lines = nil
       cmds.each do |cmd|
         stdout = IO.popen('ifconfig'){|fd| fd.readlines} rescue next
         next unless stdout and stdout.size > 0
         lines = stdout and break
       end
       raise "#{ cmd } failed" unless lines

       candidates = lines.select{|line| line =~ re}
       raise 'no mac address candidates' unless candidates.first

       maddr = candidates.first[re]
       raise 'no mac address found' unless maddr
       @mac_address = maddr.strip
     end


(man i have to get parallels installed...)

-a
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama