Last active
April 2, 2021 17:52
-
-
Save andre1810/bf18463ae43aa6f42f2d to your computer and use it in GitHub Desktop.
List Port Forwardings of vagrant machines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool. I extrapolated this into shale:
vboxmanage list vms|while read NAME ID;do vboxmanage showvminfo $ID;done|egrep "^Name: |^NIC.*name"