command-line-interface - 未知子命令 : 'execute' when using guestcontrol option

标签 command-line-interface virtualbox

我正在尝试运行 /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。尝试使用“运行”而不是“执行”和“--exe”而不是“--图像”。

此外 --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:”是对应于我的程序所在的 OS/X 目录的 windows frive。
就我而言,此批处理文件使用 windows 'cmake' 以便在 Windows 64 上编译 C 程序。它是交叉编译的替代方法,有时更好,因为您可以使用具有更高性能的 native 编译器,并且可以在其真实环境中测试可执行文件。

但是,“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 不再有效。

关于command-line-interface - 未知子命令 : 'execute' when using guestcontrol option,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33471119/

相关文章:

node.js - 无法从 Cloud Foundry CLI 登录到 Bluemix Dedicated

swift - 预定的计时器不会触发

node.js - 如何在 centos 6.4 virtualbox 客户端上使用 express 设置和配置 node.js 到 nginx 反向代理?

laravel - 在 Vagrant VirtualBox 上启用 GUI - 未定义的局部变量

linux - 如何在我的虚拟环境中启用多核?

linux - 2 个 wifi 适配器连接到 2 个独立的网络。如何只使用其中之一?

php - Symfony2 KendoUI 实现

linux - 如何清理 bash 中分隔符也在双引号内的 csv?

c# - 在 C# 中运行程序时,所有消息都转到标准输出,但标准错误不包含任何内容

python - Pycurl导入错误: SSL Backend Mismatch