Page 1 of 1

Machine-readable VBoxManage list command?

Posted: 28. Apr 2011, 23:11
by paulehoffman
Greetings. Before I put in a suggestion that "VBoxManage list" should have a --machinereadable optiton like "VBoxManage shwovminfo" does, I wanted to check if anyone knows of a way to automate the info, particularly from "bridgedifs".

Re: Machine-readable VBoxManage list command?

Posted: 28. Apr 2011, 23:17
by Perryg
Why do you need machinereadable in the list option?
To automate anything in Linux you write a script and run it.

Re: Machine-readable VBoxManage list command?

Posted: 29. Apr 2011, 16:04
by scottgus1
I use a script in my backup routine that reads the "VBoxManage showvminfo" output. It's generated by a program, so all the data should ultimately be in the same places, depending on the line you need to read. Just do some experiments, find out what you want to input and see what showvminfo outputs, and write your program to extract the data:

Code: Select all

.
.
.
"C:\Program Files\Sun\VirtualBox\vboxmanage" showvminfo CVhost > status.txt
find /i /n "State:           powered off" status.txt > nul
if "%Errorlevel%"=="0" goto startshutdown2
find /i /n "State:           saved" status.txt > nul
if "%Errorlevel%"=="0" goto startshutdown2
.
.
.

Re: Machine-readable VBoxManage list command?

Posted: 30. Apr 2011, 21:24
by paulehoffman
Perryg wrote:Why do you need machinereadable in the list option?
To automate anything in Linux you write a script and run it.
The "machinereadable" option lets you parse the output better than screen scraping. In the example I gave, bridgedifs, you need to parse the information for each element by looking for blank lines and sucking up spaces at the beginning of each line that doesn't start at the left column. Your argument would also apply to showvminfo, which someone was nice enough to add machinereadable to.