Skip to content

Instantly share code, notes, and snippets.

@andre1810
Last active April 2, 2021 17:52
Show Gist options
  • Save andre1810/bf18463ae43aa6f42f2d to your computer and use it in GitHub Desktop.
Save andre1810/bf18463ae43aa6f42f2d to your computer and use it in GitHub Desktop.
List Port Forwardings of vagrant machines
vm_infos = `vboxmanage list vms`
puts 'Port Forwardings:'
puts '---------------------------------'
vm_infos.each_line do |vm_info|
vm_name = vm_info.scan(/\"(.*)\"/)
vm_id = vm_info.scan(/.*{(.*)}/).join('')
vm_detail_info = `vboxmanage showvminfo #{vm_id}`
puts vm_name
puts vm_detail_info.scan(/NIC [0-9] Rule\([0-9]\):\s*(.*)/)
puts '---------------------------------'
end
exit 0
@axelabs
Copy link

axelabs commented Jan 28, 2016

Cool. I extrapolated this into shale:

vboxmanage list vms|while read NAME ID;do vboxmanage showvminfo $ID;done|egrep "^Name: |^NIC.*name"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment