------art_197_4708100.1141681641679
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

On 3/6/06, rtilley <rtilley / vt.edu> wrote:
>
> This is probably enough for the list to look over. What do you guys
> think -- idiomatic Ruby or not? Also, if I'm doing anything that's not
> safe (should I close 'mgmt' or 'net' somehow) please let me know.
>
> Thanks again for the feedback.
>
> require 'win32ole'
>
> # Get running process names, ids and paths (if present)
> mgmt = WIN32OLE.connect("winmgmts:\\\\.")
> mgmt.InstancesOf("win32_process").each do |p|
>    puts p.name.to_s + "\t" +
>    p.processid.to_s + "\t" +
>    p.executablepath.to_s
> end


I would do:
mgmt.InstancesOf("win32_process").each do |p|
   puts "#{p.name}\t#{p.processid}\t#{p.executablepath}"
end

puts
>
> # Get the IP, Mac Address and Gateway of Active Network Interfaces.
> net = WIN32OLE.connect("winmgmts:\\\\.")
> net.InstancesOf("win32_networkadapterconfiguration").each do |i|
>    if i.ipenabled == false
>      #puts "Interface Disabled"
>    else
>      puts i.ipaddress
>      puts i.defaultipgateway
>      puts i.macaddress
>    end
> end


I would use i only for (small) integers, but it's a question of taste of
course.

Cheers,

Han Holl

------art_197_4708100.1141681641679--