未知子命令:'execute' 使用来宾控制选项时

Unknown sub-command: 'execute' when using guestcontrol option

我正在尝试 运行 /bin/ls 通过 VirtualBox vboxmanage guestcontrol 提供的命令行界面。

this documentation 之后,我 运行 这些命令:

vboxmanage startvm centos6;
vboxmanage  guestcontrol "centos6" execute --image "/bin/ls" --username root --passwordfile pwd.txt --wait-exit --wait-stdout -- -l /usr;

我有以下 stdout :

Oracle VM VirtualBox Command Line Management Interface Version 5.0.0 (C) 2005-2015 Oracle Corporation All rights reserved.

Usage:

VBoxManage guestcontrol [--verbose|-v] [--quiet|-q] [--username ] [--domain ] [--passwordfile | --password ]

                          run [common-options]
                          [--exe <path to executable>] [--timeout <msec>]
                          [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
                          [--ignore-operhaned-processes] [--no-profile]
                          [--no-wait-stdout|--wait-stdout]
                          [--no-wait-stderr|--wait-stderr]
                          [--dos2unix] [--unix2dos]
                          -- <program/arg0> [argument1] ... [argumentN]]

                          start [common-options]
                          [--exe <path to executable>] [--timeout <msec>]
                          [-E|--putenv <NAME>[=<VALUE>]] [--unquoted-args]
                          [--ignore-operhaned-processes] [--no-profile]
                          -- <program/arg0> [argument1] ... [argumentN]]

                          copyfrom [common-options]
                          [--dryrun] [--follow] [-R|--recursive]
                          <guest-src0> [guest-src1 [...]] <host-dst>

                          copyfrom [common-options]
                          [--dryrun] [--follow] [-R|--recursive]
                          [--target-directory <host-dst-dir>]
                          <guest-src0> [guest-src1 [...]]

                          copyto [common-options]
                          [--dryrun] [--follow] [-R|--recursive]
                          <host-src0> [host-src1 [...]] <guest-dst>

                          copyto [common-options]
                          [--dryrun] [--follow] [-R|--recursive]
                          [--target-directory <guest-dst>]
                          <host-src0> [host-src1 [...]]

                          mkdir|createdir[ectory] [common-options]
                          [--parents] [--mode <mode>]
                          <guest directory> [...]

                          rmdir|removedir[ectory] [common-options]
                          [-R|--recursive]
                          <guest directory> [...]

                          removefile|rm [common-options] [-f|--force]
                          <guest file> [...]

                          mv|move|ren[ame] [common-options]
                          <source> [source1 [...]] <dest>

                          mktemp|createtemp[orary] [common-options]
                          [--secure] [--mode <mode>] [--tmpdir <directory>]
                          <template>

                          stat [common-options]
                          <file> [...]

VBoxManage guestcontrol [--verbose|-v] [--quiet|-q]

                          list <all|sessions|processes|files> [common-opts]

                          closeprocess [common-options]
                          <   --session-id <ID>
                            | --session-name <name or pattern>
                          <PID1> [PID1 [...]]

                          closesession [common-options]
                          <  --all | --session-id <ID>
                            | --session-name <name or pattern> >

                          updatega|updateguestadditions|updateadditions
                          [--source <guest additions .ISO>]
                          [--wait-start] [common-options]
                          [-- [<argument1>] ... [<argumentN>]]

                          watch [common-options]

Syntax error: Unknown sub-command: 'execute'

是的,执行似乎不再适用于最新的 5.0.10 版 VirtualBox。尝试使用 'run' 而不是 'execute' 和 '--exe' 而不是 '--image'。

同时 --wait-exit 也被抑制了。

这是我现在正在使用的命令: $ VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\SysWOW64\cmd.exe" foo.bat --username myname --verbose --wait-stdout --wait-stderr -- "/c" "f:\path\foo.bat" "arg1" "f:" "arg3"

命令在 OS/X 上执行,以便在 Windows 64 位上执行具有三个参数的批处理文件 foo.bat。第二个参数 'f:' 是 windows frive,它对应于我的程序所在的 OS/X 目录。 在我的例子中,这个批处理文件使用 windows 'cmake' 以便在 Windows 64 上编译一个 C 程序。它是交叉编译的替代方法,有时甚至更好,因为您可以使用性能更高的本机编译器,并且可以在其真实环境中测试您的可执行文件。

然而,'run ---exe' 与以前的 'execute --image' 有一些不同,因为如果命令在终端 shell 中运行良好,我在 emacs 下使用 'compile' 命令遇到困难,可能是因为 --wait-exit 不存在了。困难在于 VirtualBox VM 运行 高 CPU 消耗并且不会停止。 但是从bash来看,和以前很像。

VBoxManage 的当前文档抑制了 'execute' 和“--image”,但使用过时(且不再有效)选项的旧示例仍然存在,不幸的是增加了混乱。

更新:在 VirtualBox 5(我的是 5.2.6)上,我正在做 $ VBoxManage --nologo guestcontrol "Windows7-64" run --exe "C:\Windows\system32\cmd.exe" foo.bat --username myname --verbose --wait-stdout --wait-stderr -- "C:\Windows\SysWOW64\cmd.exe" "/c" "f:\path\foo.bat" "arg1" "f:" "arg3"

直接启动 64 位 cmd.exe 不再有效。