From: Jeff Barczewski Date: 2007-07-04T04:08:14+09:00 Subject: Re: mac addr determination ------=_Part_106392_26127554.1183489695123 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 7/3/07, ara.t.howard wrote: > > > On Jul 3, 2007, at 12:28 PM, Jeff Barczewski wrote: > > > > > > > Yes, it is not in my user path for gentoo linux either. It is in > > my /sbin > > directory which my non-admin users don't normally have in their path. > > > > > latest version. can everyone test on various platforms and report > results and/or patch? > > 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 > lines = nil > cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', > 'ipconfig /all' > > cmds.each do |cmd| > stdout = IO.popen ('ifconfig'){|fd| fd.readlines} > next unless stdout and stdout.size > 0 > lines = stdout and break > end > raise 'ifconfig 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 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 On linux I get testara.rb:23: command not found: ifconfig testara.rb:23: command not found: ifconfig testara.rb:23: command not found: ifconfig testara.rb:23: command not found: ifconfig testara.rb:13:in `mac_address': ifconfig failed (RuntimeError) from testara.rb:23 -- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy http://inspiredhorizons.com/ ------=_Part_106392_26127554.1183489695123--