View Single Post
  #6  
Old 22nd April 2010, 02:10
dfed dfed is offline
Junior Member
 
Join Date: Apr 2010
Posts: 16
Thanks: 0
Thanked 1 Time in 1 Post
Default

Apologies for the many posts, but I often nitpick my own ideas and something just struck me.

My script to determine the OS of each guests and give a config file to use in other scripts is inelegant. It also fails when a windows guest is introduced, because that wouldn't have an ssh service.

Something much more elegant would be like the following:

Code:
#!/bin/bash
for x in `ls ~/.VirtualBox/Machines/ | sort -u`; do VBoxManage showvminfo ${x} | sed -n 5,6p; done
Of course this is off the top of my head. You could use various awk/sed magicks to get the needed info. Once gotten, you could tailor scripts to the various OS platforms your guests run (automating yum vs. automating aptitude, etc.)

Helpful commands to use in scripts I've just sussed out:

Show VM operating systems:

for x in `ls ~/.VirtualBox/Machines/ | sort -u`; do VBoxManage showvminfo ${x} | sed -n 5,6p; done

list running vms:

VBoxManage list runningvms | sed '5d' | awk '{print $1}' | grep -v "All" | grep -v "(C)" | sed 's/"//' | sed 's/"//' | sort -u

List all vms:

VBoxManage list vms | sed '5d' | awk '{print $1}' | grep -v "All" | grep -v "(C)" | sed 's/"//' | sed 's/"//' | sort -u


(ETA: Yeah these need to be combed over by me more thoroughly, but you get the idea.)

Last edited by dfed; 22nd April 2010 at 03:06. Reason: cleaned up script line
Reply With Quote