问题描述:

A VirtualBox virtual machine may be launched headless or with the traditional GUI type. I've sifted through the vboxmanage documentation but can't find a way query the current type. Short of grepping running processes or X windows, what's the best mechanism to determine if a VM is headless from Bash?

Note: I also tried diffing vboxmanage showvminfo and vboxmanage guestproperty enumerate between headless and GUI sessions but the only deltas were timestamps.

网友答案:

Some ideas...

If you're using Linux try comparing their /proc/${PID} directories. Maybe you could find the open socket in fd/ or a DISPLAY env set in environ. Beware it's zero-terminated (use tr '\0' '\n').

Cheers

相关阅读:
Top